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

Jump Preventer Not Functioning Properly?

Basically I'm trying to make it so if a person jumps too much, the so called PlatformStand will activate, and deactivate after a couple of seconds.

All scripts are in a LocalScript.

--LOL Script

local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:wait()
local humanoid = char:WaitForChild('Humanoid')
local playergui = Player:WaitForChild('PlayerGui')
local Gui = playergui:WaitForChild('Team')

while true do
	if humanoid.Jump == true then
		Gui.jumping.Value = Gui.jumping.Value + 1
		wait(0.1)
	elseif humanoid.Jump == false then
		if Gui.jumping.Value == 0 then
			Gui.jumping.Value = Gui.jumping.Value - 0
			wait(0.1)
		elseif Gui.jumping.Value ~= 0 then
			Gui.jumping.Value = Gui.jumping.Value - 1
			wait(0.1)
		end
	end
end

--Jumping Script

local jumping = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild('Humanoid')

while true do
	while jumping.Value ~= 5 do
		wait()
	end
	humanoid.PlatformStand = true
	wait(2)
	humanoid.PlatformStand = false
	wait(1)
end

Located in StarterGUI:

Screenshot

Thanks, LukeGabrieI

2 comments

0

Can I ask you why you are using PlatformStand? Also I definitely know PlatformStand doesn't prevent jumping but prevents the player from moving with the directional keys.

0

Anyway, to prevent the player from literally jumping (no matter what condition) please refer to this https://scriptinghelpers.org/questions/11339/how-do-you-disable-jumping

1 answer

✓ Accepted answer

That jump bool you see in humanoids isn't meant to be used as checking if the player is jumping or not, it's used to make the player jump.

We can use the Jumping event of humanoid to check when a player jumps, used like this

Player.Character:WaitForChild("Humanoid").Jumping:connect(function()
	--stuff
end) 

But what if you want to check when the player gets back on the floor, well we can use the Freefalling event for that because it returns a bool value if the player is in the air or not

Player.Character:WaitForChild("Humanoid").FreeFalling:connect(function(val)
	if val==true then
		print('falling')
	else
		print('on ground')
	end
end) 

Also in your first script you (this doesn't matter now because u may not be using while true do anymore) but you didn't have a wait outside the if statement so if it error it would crash.

Also in your second script instead of using a while loop you should use the changed event of the value so run something when the value of that value changed instead of using the loop, like this.

local jumping = script.Parent

jumping.Changed:connect(function()
	if jumping.Value==true then
		--blah
	end
end)

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