I created a script, and It wont work, it has a spam limit, but the cooldown, wont work. Any explanation?
local spamlimit = 10000
local spamtime = 0.1
local cooldown = 5
local playerlist = {}
game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
if msg:lower() == "heal/" then
if playerlist[p] ~= true and (playerlist[p] == nil or playerlist[p][spamlimit] == nil or playerlist[p][spamlimit] - playerlist[p][1] >= spamtime) then
p.Character.Humanoid.Health = p.Character.Humanoid.MaxHealth
if playerlist[p] == nil then
playerlist[p] = {}
end
if playerlist[p][spamlimit] then
for i = 1, #spamlimit - 1 do
playerlist[p][i] = playerlist[p][i + 1]
end
playerlist[p][spamlimit] = tick()
else
table.insert(playerlist[p], tick())
end
elseif playerlist[p] ~= true then
playerlist[p] = true
Wait(cooldown)
playerlist[p] = nil
end
end
end)
end)
