i thought about making like an instance that tells me if someone is stunned or not and have a loop in the server that checks if players has this stunned instance but i think its going to be laggy, doing it on the local script would probably make a vulnerability so what would be the best way to make a stun system that isnt laggy and isnt vulnerable to exploits?
#what would be the best optimized way to make a stun system?
1 messages · Page 1 of 1 (latest)
make it event based, you dont need loops for that.
I would give every player character a "Stun" attribute boolean, set it up on all players and playerjoined characterjoined, etc. Put it under the character since stun logic is tied to the character and it will reset to default on death.
Handle your stun logic on the server, and change states based on the attribute.
PlrCharacter:GetAttributeChangedSignal('Stun'):Connect(function()
local isStunned = PlrCharacter:GetAttribute('Stun')
if isStunned then
--Stun effect.
else
--Remove stun effect.
end
end)
what if i do multiple stuns and giving extra stun time, this script will start working 5 times if i do 5x stun and it will cause some bugs i guess
imo same script logic but use renderstepped and remove stun time every 0.1 sec till it reaches zero or bigger than last stun time (sorry for bad english)