The way my game works is once the player’s hit it will set their speed to 5 then wait(.5) and set it back.
The problem is that if you hit a player the 2nd time the 1st hit will finish waiting .5 seconds and revert it to 16 anyways. This is a problem for me, because players can walk right out of combo hits.
If anyone can find the solution to this issue I would be grateful. I know it has something to do with checking, but I don’t know how to go about doing this.
One way you could do this is with coroutines. When your player strikes another player, it uses coroutine.wrap to set the speed to 5, wait 0.5, and set the speed back to 16. When they get struck again, the old coroutine is yielded, stopping it from setting the player’s speed back to 16, and a new coroutine is created that sets speed to 5, wait 0.5, and sets the speed back to 16. There’s likely a more elegant solution, just not thinking of it right now.
EDIT: Nevermind I don’t think this will work, because there’s other players in the game too. It would only work if it was 1 player getting slowed, but since the function would work for everyone it could yield their stun too if they’re stunned.
Did you try having your tool-related scripts/local/scripts remotes inside of each tool? It’s a good practice to do, and from an anti-exploiting perspective it makes your server checks significantly easier since you have a reference to the tool. That way every tool has a damager script and a remote that works only for that tool, instead of one script for every tool in the game.
An alternative if you don’t want to do that is a Dictonary that maps each tool to their respective coroutine.