What I am currently trying to achieve is that when the player jumps the desired value should be added to the leaderstats. But I am not sure how do I detect when the player jumps.
I’ve gone through some posts in the developer hub but still ain’t sure and confused.
There’s the UserInputService JumpRequest event which will fire when the player requests to jump.
You can use this in a LocalScript and :FireServer a RemoteEvent to handle it on the server.
Remember to include a debounce for each player to combat exploiters.
This event fires when the player wants to jump. The thing is has to be handled on the client, so a RemoteEvent will have to be used to change the data, but you should make it not exploitable, which means that a cooldown should be implemented
While Loop and Humanoid.Jump
I’m not so sure on this one, but you basically use a while Loop and constantly check if the player’s humanoid has the jump property set to true, which signifies that the player has jumped
Don’t use JumpRequest if you’re trying to detect when the player jumps. Use it only when you need to check if the player is attempting to jump. As well (cc @Raretendoblox), don’t use a loop here. It is largely unnecessary as events are provided in the API to check when jumps occur.
YAY!!! finally… something that actually works :') i just wanted to decrease stamina on jump and this is perfect. (I’m running a remote event on the jump while turning value (local inside script) true, if value is true and lands the value == false, and finally UIS.JumpRequest is working perfectly.