So I'm trying to make a script personally for me just for scripting practice. Then I realized this would make as a really good game. There aren't any errors in the output at all, and I have checked the wiki about 20 times. So please help.
local player = game.Players.LocalPlayer.Character
local UserInputService = game:GetService("UserInputService")
while wait(0.2) do
function onInputBegan(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.F then
local ball = Instance.new("Part", workspace)
ball.Parent = player.Torso
ball.BrickColor = BrickColor.new("Teal")
ball.Material = "Plastic"
ball.Transparency = .6
local Weld = Instance.new("Weld", ball)
Weld.Part0 = ball
Weld.Part1 = player.Torso
ball.CFrame = player.Head.CFrame
Weld.C0 = ball.CFrame:inverse()
Weld.C1 = player.Torso.CFrame:inverse()
ball.Anchored = false
wait(1)
ball:Destroy()
Weld:Destroy()
end
end
end
UserInputService.InputBegan:connect(onInputBegan)

4 comments
you didn't call the function onKeyPress.
your supposed to call the function using an event. if you got this function from userinputservice then check the events for it and link it to onKeyPress
OMG I COMPLETELY FORGOT TO DO THAT!
Still didn't work. I changed the script so you can see what I changed it to, but I may have done something wrong