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?
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