Jumping Toggle?

Aight so I was scripting a script which simply disables the player’s jump. Simple enough, right?
Then I decided to make it be able to disable or enable jumping, and I started running into issues.

I attempted to use while statements using shared variables in order to achieve this.

The key part of the code is below.

shared.JumpEnabled = false

while shared.JumpEnabled == false do
    Humanoid.JumpPower = 0
    print(Humanoid.JumpPower)	
end

while shared.JumpEnabled == true do
	Humanoid.JumpPower = 50
	print(Humanoid.JumpPower)
end

I have clearly messed something up easily and I’m just not seeing it. So, how can I fix this?

why dont you just go to starterplayer and find jump power and reset its values to your desired value

Well, although that would just disable jumping, I am looking to enable AND disable jumping. Not just turning it off completely.

What is JumpEnabled, a bool value or a variable thats set to true / false?

make a script then for loop all the players then do some stuff then

It’s a bool variable, yes.

///

I suppose a for loop may work, I’ll give that a shot.

Well your code uses two while loops that will not run indefinitely, so when the two conditions apply the script stops running.

You should do something like this:

while true do
    if shared.JumpEnabled then
        Humanoid.JumpPower = 50
    else
        Humanoid.JumpPower = 0
    end
    wait() -- EDIT: also add in a wait so your script won't crash
end

Nevermind I figured out how to do it a different way using RemoveEvents. Thanks for the help though.