I am trying to make this script kick the players once the timer reaches 0, however I have had no luck in trying to get this to work so far this is the code I have
01 | timer = game.ReplicatedStorage:WaitForChild( "Timer" ) |
02 | timer.Value = 5 |
03 |
04 |
05 | while true do |
06 | if timer.Value > = 1 then |
07 | timer.Value = timer.Value - 1 |
08 | wait( 1 ) |
09 | else return nil |
10 | end |
11 |
12 | end |
13 |
14 |
15 | -- everyone below not working |
Also should I be using a remote function/event when kicking clients?
This should work:
1 | local kickreason = "Timer ran out." --Reason for being kicked |
2 | local Timer = 5 --The timer value--How long before the players get kicked |
3 | for i = Timer, 0 ,- 1 do --For every second do this |
4 | Wait( 1 ) --Wait a second |
5 | end |
6 | for i, player in pairs (game.Players:GetPlayers()) do --For every player do |
7 | player:Kick(kickreason) --Kick all players |
8 | end |