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

Why is this jump script not working?

UIS = game:GetService('UserInputService')

UIS.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.Space then
		game.Players.LocalPlayer.Character.Humanoid.Jump = false
		print'you cant jump boi'
	end
end)

It prints but it does not prevent jumping at all. Ive also tried setting HumanoidStateType to None but that doesen't work either. Could someone fill me in on how i'm supposed to prevent jumping properly?

1 answer

✓ Accepted answer

Checking UserInputService will tell you when the player jumps AFTER he jumped, thus not preventing it.

What you should do (and I believe that's what's being done everywhere) is using a function fired with Humanoid.Changed, and every time the Humanoid changes, set Jump to false.

Should look like this:

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		char:FindFirstChild("Humanoid").Changed:connect(function()
			char.Humanoid.Jump=false
		end)
	end)
end)

Didn't test it but I think it should work.

__

If you want it inside a LocalScript,

local plr=script.Parent.Parent
local hum=plr.Character:FindFirstChild("Humanoid")
hum.Changed:connect(function()
hum.Jump=false
end)

Just put that inside a LocalScript inside StarterGui/StarterPack

13 comments

0

Doesn't work and doesn't print anything if I put a print in it.

0

I tested it and it worked. Make sure it's in a normal Script inside workspace and its not disabled.

0

Any way I could apply this in a LocalScript?

0

And by the way, the right way to print is: print("what you want to print here") or print('what you want to print here')

0

Updated my reply with the way to do it for a LocalScript

0

Out of curiosity, my setup was http://i.imgur.com/5fGZIsZ.png, which im pretty sure is identical to that. Why isnt mine working?

0

Your print wont work because it's not written appropriately. As for the jump part it really should work, remove what you've written before about UserInputServcice.

0

Also your code doesen't work either.

0

And that IS the correct way to print. Ive done it before in the same way with a string.

0

Oh my bad that printing method does work. Sorry didn't know about it. 1sec I'll test the method with the Local Script. I DID test the global script way tho, and it worked for me.

0

Yep, the Local Script way did work. Just literally try it with ONLY that in your script.

0

Eh i can just use the global

0

It works better in a LocalScript tho. Try it, just don't put anything else and put it in StarterPack

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