RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"e key for shooting the ball"
-- local script local UserInputService = game:GetService("UserInputService") local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local ball = character.Ball -- assuming the ball is a part in the character local function shootBall() local bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) bodyVelocity.Velocity = character.HumanoidRootPart.CFrame.lookVector * 100 bodyVelocity.Parent = ball wait(2) bodyVelocity:Destroy() end UserInputService.InputBegan:Connect(function(input, gameProcessedEvent) if input.KeyCode == Enum.KeyCode.E and not gameProcessedEvent then shootBall() end end)