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

Jump Prevention [closed]

Asked by 10 years ago

I have a script that will take away 15% of a player's stamina whenever they jump. The only problem is I cannot figure out how to keep players from jumping when they have less than 15% stamina. I have tried humanoid.Jump = falsebut that didn't work. I looked on the wiki for ways to keep a player from jumping, I found UserInputService but I am not quite sure how I would check to see if the localplayer has activated the JumpRequest event.

Here is the code that I am using right now:

wait(1)
local player = game.Players.LocalPlayer
hum = Workspace[player.Name].Humanoid
stamina = player.scores.Stamina

hum.Jumping:connect(function()
    if stamina.Value < 15 then
        hum.Jump = false
    else
        stamina.Value = stamina.Value - 7.5
    end
end)

If somebody could tell me what I am doing wrong and what I could do to fix that I would be very appreciative.

0
The reason this wouldn't work is because that .Jumping event fires AFTER the player has already jumped. The .Changed event, on the other hand, fires before they jump, so you can run your stamina check before they can jump. Chaotic_Cody 154 — 10y
0
There is a free model that CloneTrooper1019 made. FromLegoUniverse 264 — 10y
1
My question had already been answered. I read Frostftw's post and understood that I was doing it at the wrong time. Thanks for explaining it though, chaoticregandpledge. FearMeIAmLag 1161 — 10y

Locked by NinjoOnline and BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
10
Answered by
modFrost 130
10 years ago

NOTE TO FUTURE EXPLORERS:

There's a much better (and easier) way to disable Jumping now: set Humanoid.JumpPower to 0.


All you have to do is set the jump to false everytime the humanoid .Changed fires.

local Player = game:service'Players'.LocalPlayer
local Character = Player.Character
local Humanoid = Character:findFirstChild("Humanoid")
Humanoid.Changed:connect(function()
    Humanoid.Jump = false
end)

All this does is disable jumping, if you wish to expand do so.

Ad