I have a footstep sound system, however you can easily exploit it to spam the sounds.
The way I have it right now is:
The Animate localScript has an added if
statement in the keyFrameReachedFunc
function:
function keyFrameReachedFunc(frameName)
if (frameName == "End") then
local repeatAnim = currentAnim
-- return to idle if finishing an emote
if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
repeatAnim = "idle"
end
local animSpeed = currentAnimSpeed
playAnimation(repeatAnim, 0.0, Humanoid)
setAnimationSpeed(animSpeed)
end
-- this here
if(frameName == "WalkSound") then
script.Parent.Scripts.Walk:FireServer()
end
end
Then, the server handles the event and plays the sounds. (there is a security feature that checks if the player firing the remote is that character)
The obvious issue here is that you can spam your own footstep sounds.
How can I prevent that while still replicating to other players?
I tried editing the RbxCharacterSounds script, but to no avail since there isnt an easy way to detect keyFrameReached on a already playing animation
Also, I use keyFrameReached so the sounds completely line up, my issue with a while loop system was that console and mobile players’ sounds didnt line up with character speed (if you move the joystick halfway out, not fully) or if you walk into a wall at an angle, slowing you down
Any help?