I am sending the input of a player clicking over to a script using a remote event. I then reference two attributes with no current use, but the important part is I calculate the debounce on the server side to avoid exploiters messing with it had it been in a local script. I print “ATTACKED” whenever the attack is supposed to take place but I see it completely ignores the debounce table and prints whenever I spam click instead of printing every five seconds. How would I go about solving this?
LOCAL SCRIPT:
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local RS = game:GetService("ReplicatedStorage")
local M1vnt = RS.Events.M1
mouse.Button1Down:Connect(function()
M1vnt:FireServer(char)
end)
SEVER SCRIPT:
local RS = game:GetService("ReplicatedStorage")
local M1vnt = RS.Events.M1
M1vnt.OnServerEvent:Connect(function(plr,char)
local attribute = char:GetAttribute("EquippedCharacter")
local incombat = char:GetAttribute("InCombat")
local debounces = {}
--M1 WORK FOR [[TestCharacter]]
if attribute == "TestCharacter" then
print("ATTACKED")
if char == nil then
return
end
local Humanoid = char:FindFirstChild("Humanoid")
if Humanoid == nil then
return
end
if Humanoid.Health < 0 then
return
end
if debounces[plr] then
return
end
debounces[plr] = true
task.wait(5)
if debounces[plr] then
debounces[plr] = nil
end
end
end)
As you can see, completely ignores the debounce. I checked countless discussions on serverside debounce and even followed 3 tutorials and they all claim this to work, yet, my code does its own thing.
