RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"e key for passing the ball Starter Gui"
-- LocalScript in StarterGui local UserInputService = game:GetService("UserInputService") local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local ball = character:WaitForChild("Ball") local function onInputBegan(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.E and not gameProcessedEvent then -- Add your code for passing the ball here ball.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5) -- Adjust the position as needed local bodyVelocity = Instance.new("BodyVelocity", ball) bodyVelocity.Velocity = character.HumanoidRootPart.CFrame.lookVector * 50 -- Adjust the force as needed wait(1) -- Adjust the time before the force is removed bodyVelocity:Destroy() end end UserInputService.InputBegan:Connect(onInputBegan)