Kick All Players Script

I was wondering how to make a script that kicks all players after some amout of time in game.

2 Likes
wait(100)
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
   v:Kick("Timer has ran out")
end
12 Likes
local timeleft = yourtimeleft -- (for me example: 500)
local kickmessage = "yourkickmessagehere"  -- ( for me example: Time has ran out. )

function KickAllPlayer()
      for i, v in pairs(game:GetService("Players"):GetPlayers()) do
             v:Kick(kickmessage)
      end
end

while true do
wait(1) 
      -- Perform checking time left.
        if timeleft > 0 then
               -- Time is not ran out, perform subtract.
                timeleft -= 1
else
        -- call kick all player function:
        KickAllPlayer()
        end
end
2 Likes

Why have a whole loop instead of a simple wait(n)?

1 Like
wait(10) -- waits 10 seconds and then kicks
for index, player in pairs(game.Players:GetPlayers()) do -- go thru every single player
    player:Kick("e") -- kick the player
end -- end the for loop
1 Like