Hi. I made a basic script that does a timer and I wanted to kick you when the timer ends.
Here is the script:
local time = 400
for i = 1,400 do
wait(1)
time = time - 1
script.Parent.Text = tostring(time)
end
Hi. I made a basic script that does a timer and I wanted to kick you when the timer ends.
Here is the script:
local time = 400
for i = 1,400 do
wait(1)
time = time - 1
script.Parent.Text = tostring(time)
end
local timer = 400
while task.wait(1) do
timer -= 1
script.Parent.Text = tostring(timer)
end
player:Kick(reason)
will that kick the player when the timer hits 0? ill make my own variables dont worry
Yeah, the player:Kick(reason)
line will only be able to run once the while loop is finished
The above post keeps going on forever with no stop – this has a break
local timer = 400
while task.wait(1) do
timer -= 1
if timer == 0 then
player:Kick(reason)
break
end
end
This is wrong – it’ll keep going on forever with no stop.
isnt break used inside a loop? will this script work?
local function onCharacterRemoving(char)
if timer == 0 then
local player = game.Players:GetPlayerFromCharacter(char)
player:Kick("Sorry")
end
end
ok yes sorry i just woke up the above code will FINALLY work
True, didn’t notice that
local timer = 400
while task.wait(1) and timer > 0 do
timer -= 1
script.Parent.Text = tostring(timer)
end
player:Kick(reason)
there needs to be context to it, does it spam onCharacterRemoving?
only when the timer reaches 0 i belive but i havent tested it
…can you test it, my script, and Orbular3’s script?
orbulars script and urs both work, but i end up with an error
local Player = game:GetService("Players")
Player:Kick("Yes")
game:GetService("Players")
returns the service “Players”, not an actual player.
how would i end this then?
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
player:Kick("nil")
If by that you mean the function, then use return
local timer = 400
while (timer > 0) do
timer -= 1
wait(1)
end
player:Kick(reason)
@Orbular3 Even simpler solution.
k thanks for your help i finally got the kick working
local player = game.Players.LocalPlayer
for i = 400, 0, -1 do
task.wait(1)
end
player:Kick("Timer ended!")
local player = game.Players.LocalPlayer
for i = 400, 0, -1 do
script.Parent.Text = tostring(i)
task.wait(1)
end
player:Kick("Kicked!")