For some context, I currently have a local script that listens for a specific input and then fires a RemoteFunction. This RemoteFunction checks the HumanoidStateType, Stamina, and all other conditions and returns true if these conditions are valid, the local script that gets a returned value plays the animation and effect.
However on the server before I return the value, I currently use a loop wrapped in a coroutine that periodically subtracts a certain amount of stamina from the Player’s Stamina pool.
The dilemma I’m facing is whether or not it’s worth shifting the loop back onto the client in favour of performance, in addition to this, it would look a lot smoother.
Some questions I have are as follows:
What would be the best way to update the server’s stamina value, since there are other movement mechanics in my game that use up stamina and need the server for validity checks? (Since the client has a stamina value different from the server, it would cause a lot of issues.)
Is it better to Tween or use a loop when manipulating the stamina value? If it’s on the client, it should be relatively easy to do both.
If Tweening or looping the stamina value proves to be quite inefficient, is there a more event driven approach?
Maybe you could try having a stamina value and making an event to see when it has been changed then send that to the server to update your value there? For the sake of not having to fire an event too often, maybe only fire it when there’s been a certain increment of change?
I would probably do tweeting just because, in my opinion, it’s better performance wise and easier to control (but just my personal opinion)
And I would think either one of these are viable options and I’m not sure of anything if they don’t work but I’ll think on it and edit this as needed.
[Edit: It’s also been a while since I’ve used studio so if none of that makes sense, my bad. I’ll try to explain it better]
These are all definitely valid Ideas, however the main issue behind using events in this case is that it could be easily exploitable by the client.
If I create an event that can manipulate the Server’s reading of the player’s stamina from the client, they could practically give themselves infinite stamina, and as a result break the game.
Yea, tweening is probably the best way to go about it, but I’ll keep a look out for other methods anyways.
Yeah I see your point and it would be easily exploitable. Maybe you could add a threshold/anti exploit to your stamina system? Like using the server to see how much it is increasing by and how often, and if your game isn’t doing that or they didn’t actually do something to have their stamina increased then you could see they’re an exploiter. Basically checking to see if the server sent for a stamina change, then it should update. Otherwise the client is trying to change it on their own.
As for now, I’ll definitely have to mess around a bit with my system and see what I can do.
However, I’m not keen on having to implement an anti-exploit that targets this specific issue.