I want a script that when you jump you lose stamina. I try to search with the space key but that dont work....
You can use either Jumping
or StateChanged
. They are both events of a Humanoid that can be used to tell when a Humanoid is jumping. Because they are events, you would connect them to functions, like so:
Using Jumping
:
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character.Humanoid.Jumping:Connect(function() -- Code here end) end) end)
Using StateChanged
, which fires with two arguments, the original state and the new state of the Humanoid:
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character.Humanoid.StateChanged:Connect(function(originalState, newState) -- Code here end) end) end)
By using the code given, you can expand upon what I gave you as examples to accomplish what you're looking to do.