Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I prevent jumping?

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

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)

2 comments

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.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.