i’m currently making a fast-paced tag game on roblox, but i’ve realized that when the remoteevent is recieved on the client, it fires twice. i’ve tried a debounce, which for some reason didnt work.
this is my function that fires the event from the server to all clients:
local function send(…)
events.serverInput:FireAllClients(…)
end
this is my reciever on the client:
events.serverInput.OnClientEvent:Connect(function(character, action, originPos, endPos, distance)
if inputDebounce then return end
inputDebounce = true
print("fired")
if action == "dash" then
trail(character, 10, 0.03, 0.3, 0.6, character:WaitForChild("Body Colors").TorsoColor3)
elseif action == "doublejump" then
trail(character, 4, 0.05, 0.3, 0.6, character:WaitForChild("Body Colors").TorsoColor3)
elseif action == "dive" then
lightningvfx(character, originPos, endPos, distance)
end
wait(0.5)
inputDebounce = false
end)
the weirdest part about all of this is that the issue only happens on some servers, which has led me to believe it might be an issue with roblox itself. the only posts i’ve found on it have said to add a debounce, and i’ve tried with numerous cooldowns. the shortest cooldown i can do without messing up the vfx is 1 (due to the game being fast-paced), and it still fires twice with cooldowns greater than 1 for some reason.
should i just try a different approach to handling the inputs, such as adding vfx on the client and trying to sync it to the server without a remoteevent? if so, i want to know if the wait() function will delay scripts for the same amount of time without interference from client and server speeds.
notes for context:
- the reciever is not nested in anything
- i’ve checked the send function with prints and it fires once