I am trying to make a world with a lot of forced perspective, and I really need to disable jumping to go along with that! I don't need people jumping my walls. Could someone please give me some help in making a script that disables that. I am trying to learn the basics, but I need to get this done soon as I like having my game in an open beta format, but don't need any noobs receiving backstage access. Thanks, guys!
Inset a script then:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local humanoid = character:findFirstChild("Humanoid") if humanoid then humanoid.Changed:connect(function(property) if humanoid.Jump == true then humanoid.Jump = false humanoid.Sit = false humanoid.PlatformStand = false end end) end end) local character = player.Character if character then local humanoid = character:findFirstChild("Humanoid") if humanoid then humanoid.Changed:connect(function(property) if humanoid.Jump == true then humanoid.Jump = false humanoid.Sit = false humanoid.PlatformStand = false end end) end end end)
I'm sure a simple
while true do wait() if(script.Parent.Parent.Character:FindFirstChild("Humanoid")) then script.Parent.Parent.Character.Humanoid.Jump = false end end
as a script in StarterPack or StarterGui would do.
I've been waiting for an explanation just like you for a very long time. I've found the solution, though.
When the game starts, your character takes a very short time to load. Even the humanoid takes a short time to be added. We can't use FindFirstChild as easily, since that would return false. Instead, use WaitForChild. WaitForChild, as the function's name implies, will wait for the object inside its brackets to some into existence.
Try out this code that I made:
player = game.Players.LocalPlayer player.CharacterAdded:connect(function(c) c:WaitForChild("Humanoid").Changed:connect(function(k) c.Humanoid.Jump = false end) end)
Remember, make a local script and put it into the StarterGui to make it work!