I usually like to wire a debounce to each player that touches the brick, rather than make the whole server conform to the same debounce.
local touchers = {}
local requiredKills = 2
local debouncetime = .5
local function debounce(player)
local lasttimetouched = debouncetime
local playerintable = touchers[player.Name]
if playerintable then
lasttimetouched = tick() - touchers[player.Name]
if lasttimetouched >= debouncetime then
touchers[player.Name] = tick()
end
else
touchers[player.Name] = tick()
end
return lasttimetouched >= debouncetime, lasttimetouched
end
script.Parent.Touched:Connect(function(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player and player.Character.Humanoid.Health > 0 then
local debounce, timelasttouched = debounce(player)
if debounce then
local stats = player:findFirstChild("leaderstats")
local kills = stats and stats:findFirstChild("Kills")
if kills then
if kills.Value >= requiredKills then
else
local difference = requiredKills - kills.Value
local plural = difference > 1 and "s" or ''
print( string.format ( "You need %s more kill%s to do that", difference, plural) )
end
else
print("can't find stats")
end
else
print(timelasttouched)
end
end
end)