Hello im making a stamina script where the stamina refills to 100 ANYTIME it isn’t already at 100.
Im doing this with a while loop (Does anyone have a better way of doing this without a while loop?)
Should I do this inside a server script or a local script?
This should be serversided, as it would allow for people to easily exploit themselves inf stamina regen or whatever. Use RunService with the DeltaTime parameter to correctly regenerate the amount of stamina that should be given per frame.
I would not make this server-sided, this is bad UX for the user…
EDIT: Instead of making this server-sided, I would keep both a client value and a server value.
I would “always” trust the client with its stamina value and on the server just calculate whether or not the amount of time they have been running is possible with their current stamina.
This way, you validate the sprinting whilst not sacrificing UX for the sake of “security”. It is always better to prefer UX and offer them a not “laggy” input when sprinting. (in case you were going to handle toggle sprinting on the server instead of the client of course).
You could make a sanity check on server by checking when the player started regenerating and now and checking if that amount of stamina is possible in that time frame.