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

Jump Preventer Not Functioning Properly?

Asked by 6 years ago
Edited 6 years ago

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

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. JoeRaptor 72 — 6y
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 JoeRaptor 72 — 6y

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago

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)
Ad

Answer this question