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.

3 comments
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.
There is a free model that CloneTrooper1019 made.
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.