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

How do I prevent jumping?

Asked by 10 years ago

I have this code below and I would like to know how to modify it to prevent a player from jumping. I have tried looking for a solution but could not find one. There are no errors in the output.

wait(1)
local player = game.Players.LocalPlayer
hum = Workspace[player.Name].Humanoid

hum.Jumping:connect(function()
    hum.Jump = false
end)

1 answer

Log in to vote
1
Answered by 10 years ago

I had the same problem about a year ago. You have to set hum.Jump to false whenever the humanoid changes. You also don't need the local in front of player as you want it to be used throughout the script, not within a specific scope.

wait(1)
player = game.Players.LocalPlayer
hum = workspace[player.Name].Humanoid

hum.Changed:connect(function()
    hum.Jump = false
end)
0
It is a good idea to use local variable whenever possible, even when they're on the global scope anyways. They make your code more readable and more efficient. Perci1 4988 — 10y
1
They are not required and they don't always make it more readable or more efficient. It is a matter of personal opinion, not making me wrong, ergo making the downvote unnecessary. FearMeIAmLag 1161 — 10y
Ad

Answer this question