Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Jump cooldown script makes it so players can't jump at all may someone help me find the error?

Asked by 3 years ago

The script below is meant to put a 1 second cooldown on jumping, basically what I'm trying to do is make it so players can't spam jump. Instead, what my script does is disables jumping entirely which is not ideal. Here it is:

local Jumped = false
local plr = game.Players.LocalPlayer
local Char = plr.Character
local humanoid = Char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local jumpCoolDown = 1    

humanoid.JumpPower = 0 

UIS.InputBegan:Connect(function(input)
    if input.Keycode == Enum.KeyCode.Space and Jumped == false then
        Jumped = true 
        humanoid.JumpPower = 50
        wait(0.1)
        humanoid.JumpPower = 0 
        wait(jumpCoolDown)
        Jumped = false  
    end
end)

Can someone suggest a fix or maybe tell me a better method to doing this, thank you.

Tiwam.

1 answer

Log in to vote
0
Answered by
To0_ny 141
3 years ago

ok......

so...

sorry to say this but you made a spelling mistake.....

ur script was fine, everything was working...

line 11...

its KeyCode not Keycode

you forgot to make the "C" capital...

script:

local Jumped = false
local plr = game.Players.LocalPlayer
local Char = plr.Character
local humanoid = Char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local jumpCoolDown = 1    

humanoid.JumpPower = 0 

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.Space and Jumped == false then -- I fixed it for you :)
        Jumped = true 
        humanoid.JumpPower = 50
        wait(0.1)
        humanoid.JumpPower = 0 
        wait(jumpCoolDown)
        Jumped = false  
    end
end)

Make sure not to make spelling mistakes ;)

Ad

Answer this question