local Timer = (Number)
local Kills = (Number)
local Waited = false
-- Called when a player is killed...
-- Most credits to @Maelstorm_1973
local function playerKilled()
Kills += 1
if waited == false then
waited = eventWait(eliminations.Changed, timeout)
end
end
Edit: Forgot to add the part to make the counter and function it
If the kills are meant to reset after a certain amount of time has passed after the last kill (sorta like a Combo counter), then I’d suggest having a structure like this:
Kill Received Event Fires:
If variable expirationThread exists
task.cancel(expirationThread)
expirationThread = nil
Do existing logic…
Spawn a new thread with task.delay(expireTime, func)
Keep track of this thread (assign the expirationThread variable to the result of the call)
func should be a function which resets the kill counter
The thread cancellation logic is to make sure that the kills don’t unintentionally get reset when a new kill is received.
local eliminations = Instance.new("IntValue")
eliminations.Value = 0
local waited = false
local timeout = 10
--
-- Whatever code you're doing...
--
-- Called when a player is killed...
local function playerKilled()
local value = eliminations.Value
value += 1
eliminations.Value = value
if waited == false then
waited = eventWait(eliminations.Changed, timeout)
end
end