Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script not kicking players when required?

Asked by
Robb12 12
5 years ago

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

01timer = game.ReplicatedStorage:WaitForChild("Timer")
02timer.Value = 5
03 
04 
05while 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
View all 28 lines...

Also should I be using a remote function/event when kicking clients?

1 answer

Log in to vote
0
Answered by
haba_nero 386 Moderation Voter
5 years ago
Edited 5 years ago

This should work:

1local kickreason = "Timer ran out."--Reason for being kicked
2local Timer = 5--The timer value--How long before the players get kicked
3for i=Timer,0,-1 do--For every second do this
4Wait(1)--Wait a second
5end
6for i, player in pairs(game.Players:GetPlayers()) do--For every player do
7player:Kick(kickreason)--Kick all players
8end
Ad

Answer this question