Can someone help me with a problem in this script? The problem is that when I made a "Spamlimit", it only made it for how many times you could heal. It would break every time I said "heal/", even if it was not past the spam time. Could someone fix this error please? Here's the script:
local spamlimit = 3
local spamtime = 0.4 -- if spamlimit is reached within this time, the cooldown is activated
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)
