RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a realistic soccer ball script where if you press "q" it shoots the ball"
-- local script local ball = script.Parent local player = game.Players.LocalPlayer local function onKeyPress(actionName, userInputState, inputObject) if userInputState == Enum.UserInputState.Begin and actionName == "Shoot" then local force = (inputObject.Hit.p - ball.Position).unit * 500 ball:SetNetworkOwner(player) ball:SetNetworkOwnerScript(script) ball:SetNetworkPosition(ball.Position, true) ball:SetVelocity(force) end end player.Character.Humanoid.Changed:Connect(function() player.Character.Humanoid.JumpPower = 0 player.Character.Humanoid.WalkSpeed = 0 player.Character.Humanoid.HipHeight = 0 player.Character.Humanoid.AutoRotate = false player.Character.Humanoid.AutoRotateOffset = 0 end) player.Character.Humanoid.Died:Connect(function() ball:SetNetworkOwner(nil) ball:SetNetworkOwnerScript(nil) ball:SetNetworkPosition(ball.Position, true) ball:SetVelocity(Vector3.new(0, 0, 0)) end) game:GetService("UserInputService").InputBegan:Connect(onKeyPress)