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 = false
but 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.
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.
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?