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

Why isn't my for loop teleport script working? For loop teleport not working..

Asked by 7 years ago

So I wrote a Server Script to teleport ALL players to a position when the intermission is up. I thought I could use a for loop to teleport them all but it doesn't seem to be working.

I'll explain with comments in the code block below..

01local players = game.Players:GetChildren()
02local roundRunning = false
03local Intermission = true
04 
05if Intermission == true then
06    local intermissionHint = Instance.new("Hint", workspace)
07    for i = 30, 0, -1 do
08        intermissionHint.Text = "Intermission: "..i
09        wait(1)
10        if i == 0 then
11            wait(1)
12            intermissionHint:Destroy()
13            Intermission = false
14            roundRunning = true
15        end
View all 24 lines...

Anyone got any idea why this isn't working??

1 answer

Log in to vote
0
Answered by
Nidoxs 190
7 years ago
Edited 7 years ago

Personally, I would use a pre-determined function in collaboration with your Intermission If Statement.

01local players = game.Players:GetChildren()
02local roundRunning = false
03local Intermission = true
04 
05function teleportPlayers()
06    for i,v in pairs(players) do
07        HRP = v.Character.HumanoidRootPart
08            HRP.CFrame = CFrame.new(23.09, 11.473, 8.84)
09    end
10end
11 
12if Intermission == true then
13    local intermissionHint = Instance.new("Hint", workspace)
14    for i = 30, 0, -1 do
15        intermissionHint.Text = "Intermission: "..i
View all 25 lines...
0
It's working now! Thanks, don't see much of a different, but it's working. Thanks! :D andyad13 74 — 7y
Ad

Answer this question