Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --script made by gavdingo
- --youtube: Boss Developer
- local plr = game.Players.LocalPlayer --gets player
- plr.CharacterAdded:Connect(function(char) --dectects when character loads
- --defining variables
- local hum = char:WaitForChild("Humanoid")
- local jumped = false
- local inputservice = game:GetService("UserInputService")
- inputservice.InputBegan:Connect(function(i)
- --detects if spacebar is pressed
- if i.KeyCode == Enum.KeyCode.Space then
- local state = hum:GetState()
- if jumped == false and state == Enum.HumanoidStateType.Freefall then --checks if player is in air and has not double jumped yet
- jumped = true --setting debounce
- hum:ChangeState(Enum.HumanoidStateType.Jumping) --jumps the player
- end
- end
- end)
- hum.StateChanged:Connect(function(old, new)
- if new == Enum.HumanoidStateType.Landed then --restes rebounce when player lands back on the ground
- jumped = false
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement