Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UserInputService = game:GetService("UserInputService")
- script.Parent = owner.Character
- local character = script.Parent
- local humanoid = character:WaitForChild("Humanoid")
- local doubleJumpEnabled = true
- humanoid.StateChanged:Connect(function(oldState, newState)
- if newState == Enum.HumanoidStateType.Jumping then
- if not doubleJumpEnabled then
- wait(.2)
- if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
- doubleJumpEnabled = true
- end
- end
- elseif newState == Enum.HumanoidStateType.Landed then
- doubleJumpEnabled = true
- end
- end)
- UserInputService.InputBegan:Connect(function(inputObject)
- if inputObject.KeyCode == Enum.KeyCode.Space then
- if doubleJumpEnabled then
- if humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
- humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
- spawn(function()
- doubleJumpEnabled = true
- end)
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement