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

when timer hits 0 teleport all players?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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!

Ad
Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
9 years ago

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

0
for some reason it didn't work. All it does it just countdown from 10?! Can you please fix this? :) docrobloxman52 407 — 9y
Log in to vote
0
Answered by
Relatch 550 Moderation Voter
9 years ago
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
0
1. No Explanation 2. Doesn't work EzraNehemiah_TF2 3552 — 9y
0
Fine, No Explanation. I'll undownvote. EzraNehemiah_TF2 3552 — 9y

Answer this question