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

How to make players move back to lobby?

Asked by 10 years ago
minigames = game.Lighting.Minigames:GetChildren()

h = Instance.new("Hint", game.Workspace)

while true do

    if game.Players.NumPlayers > 1 then
        h.Text = "Deciding what minigame to play"
        wait(5)
        ranGame = math.random(1, #minigames)
        gameChosen = minigames[ranGame]
        h.Text = "Minigame Chosen: " .. gameChosen.Name
        wait(5)
        gameChosenClone = gameChosen:Clone()
        gameChosenClone.Parent = game.Workspace
        wait(2)
        -- Teleport players to the map --
        spawns = gameChosenClone.Spawns:GetChildren()
        for i,v in pairs(game.Players:GetPlayers()) do
            name = v.Name
            check = game.Workspace:FindFirstChild(name)
            if check then
                checkHumanoid = check:FindFirstChild("Humanoid")
                if checkHumanoid then
                    check:MoveTo(spawns[i].Position)                    
                end
            end
        end
        for i = 3, 1, -1 do
            h.Text = "Game begins in: " .. i
            wait(1)
        end
        -- Countdown till the game ends --
        for i = 10, 1, -1 do
            h.Text = "Time left: " .. i
            wait(1)
        end
        h.Text = "Game ended!"
        wait(2)
        -- Teleport players back to Lobby --
        -- Script here --

        wait(1)
        gameChosenClone:Destroy()
    else
        h.Text = "There needs to be more than 1 player to begin"
    end
    wait(1)
end

Ok so this is a script, main script, that if there is more tahn 1 player, the game chooses and random map from lighting, and takes the players to the map, but when the game is over, the map is destroyed and the players are left to fall till they die and spawn back in the lobby. Where it has -- Script Here -- (Line 41 )I want it to take all the players back to the spawns in Lobby. Anyone help?

Will this work?

        local people =(game.Players:GetPlayers())
        for i,v in pairs(people) do
            v.Character:MoveTo(game.Workspace.Spawns)
        end
0
Please make an attempt at what you are asking for before simply demanding code or your question will be closed. Articulating 1335 — 10y
0
I did. Do I add the attempt to it also? I'll add now NinjoOnline 1146 — 10y
0
ok done NinjoOnline 1146 — 10y

1 answer

Log in to vote
0
Answered by
Dominical 215 Moderation Voter
10 years ago

No this will not work because you are not returning the correct value.

for i,v in pairs(game.Players:GetPlayers()) do
v.Character:MoveTo(Vector3.new(game.Workspace.Spawns)) -- Spawns can't be a model or else it won't work!
end
0
What does it mean if can't be a model?? Does it have to be a spawnpoint???? Akorede09broth 9 — 3y
Ad

Answer this question