Need a little help

So I’m making this Jump Boost thingy for my gamemode, but it runs the code so many times when i press the key. I would like to only make it run once when i press the key.

Here’s my code:

I’ve been trying to many different things, but nothing seems to work.

I highly appericiate all your help.

You can try using the SetupMove hook. If you look at the second example. where it shows disable jumping, but instead do whatever you need to. Run this hook server sided, if you run it client sided, the client might cheat.

I agree; use a serverside hook. Also, if you only want it to happen once then add a variable to track it and a way to reset the variable.

Double jump would track IN_JUMP but would allow double-jump to occur when the player is not OnGround and not alreadyDoubleJumped… The alreadyDoubleJumped var would get reset when OnGround and that completes the cycle.

So, depending on what you want to do, add more logic.

If you were to only use a serverside hook, you’d lose out on prediction. That means when you try to double jump, your client won’t know about it until the server networks it. This is bad. It makes movement laggy and would work differently to the rest of the game’s movement.

I’ve made an addon that shows how predicted double jumping can be implemented: https://github.com/wiox/archive/tree/master/gmod-multi-jump-master