Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

when timer hits 0 teleport all players?

Can anyone help me with my script? I have a timer and it counts down from 0, then it is going to teleport all the players in the game to that brick. Can you help me?

local players = game.Players:GetPlayers()
for test1 = 10, 1, -1 do
	test2 = Instance.new("Hint", game.Workspace)
	test2.Text = "There is " ..test1.. " seconds left"
	wait(1)
	game.Workspace.Message:remove()
	wait(1)
	players.Character:MoveTo(game.Workspace.SpeedBrick.Position)
end

3 answers

✓ Accepted answer

Using Dyler3's script, I'll edit it a little, the problem is with the dead variable not updating. Don't use the players variable.


#Final Product

local test2 = Instance.new("Hint", workspace)

for test1 = 10, 0, -1 do --Replace 10 with how many seconds you want to wait.
    test2.Text = "There is " ..test1.. " seconds left"
    wait(1)
end
game.Workspace.Message:Destroy()
for i, v in pairs(game.Players:GetPlayers()) do
    v.Character:MoveTo(workspace.SpeedBrick.Position)
end

Hope it helps!

##Your problems You have a couple problems with your script. The first is that you used the for statement incorrectly. It would work like this, just not the way you want it to. Your second problem comes in when you're trying to move the players.


##Fix Ok, so for the first part, we simply want it to wait one second for each iteration, and then update the text. To do that, we'll shorten the for statement down to this:

local players = game.Players:GetPlayers()
for test1 = 10, 1, -1 do
	test2 = Instance.new("Hint", game.Workspace)
	test2.Text = "There is " ..test1.. " seconds left"
	wait(1)
	game.Workspace.Message:remove()
end

Now that's fixed, and will work how you want it to. Here's for the next part. Here, we'll teleport each player individually to the brick:

wait(1)
for _,Player in pairs(players) do
	Player.Character:MoveTo(game.Workspace.SpeedBrick.Position)
end

Now, this should work as well. It is another for statement that iterates over each player, and moves them to the brick. So, let's put it together, and for the final result we get this:

local players = game.Players:GetPlayers()
for test1 = 10, 1, -1 do
	test2 = Instance.new("Hint", game.Workspace)
	test2.Text = "There is " ..test1.. " seconds left"
	wait(1)
	game.Workspace.Message:remove()
end
wait(1)
for _,Player in pairs(players) do
	Player.Character:MoveTo(game.Workspace.SpeedBrick.Position)
end

There ya go


Ok, so now it should work. If you have any further problems/questions, please leave a comment below. Hope I helped :P

####-Dyler3

1 comment

0

for some reason it didn't work. All it does it just countdown from 10?! Can you please fix this? :)

for test1 = 10, 0, -1 do
    test2 = Instance.new("Hint", workspace)
    test2.Text = "There is " ..test1.. " seconds left"
    wait(1)
end

test2:Destroy()

for i, v in pairs(game.Players:GetPlayers()) do
	v.Character:MoveTo(workspace.SpeedBrick.Position)
end

2 comments

0
  1. No Explanation 2. Doesn't work
0

Fine, No Explanation. I'll undownvote.

This discussion is preserved as it was. New answers, comments, and votes are closed.