It’s nice to account for Delta time, even if I don’t like how task.wait’s one works.
local timer = 400
while (timer > 0) do
timer -= task.wait(1)
end
player:Kick(reason)
A better option would be to do this with a heartbeat connection themselves.
local TimeRemaining = 400
local PlayerKickTimer
PlayerKickTimer = RunService.Heartbeat:Connect(function(deltaTime)
TimeRemaining -= deltaTime
Timer.Text = "Timer: ".. math.ceil(TimeRemaining)
if TimeRemaining > 0 then
return
end
PlayerKickTimer:Disconnect()
PlayerKickTimer = nil
player:Kick()
end)
And another much simpler alternative:
(This one you can’t change the timer)
task.delay(400, player.Kick, player, "KickMessage")