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

How to fix a round script that teleports a player to a map then back?

Asked by 7 years ago
local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")

while true do
-- Intermission
for i = 15,0,-1 do
status.Value = "Intermission: "..i
wait(1)
end
status.Value "Game in progress.."
local map = game.ServerStorage.RockyLands
map:Clone().Parent = game.Workspace
wait(15)
game.Workspace.RockyLands:Destroy()
status.Value = "Round over!"
end

How would I make the players teleport to the rocky lands and teleport back to the lobby? How would I do that without messing up the script. Currently the player is in the lobby where the spawnpoint is too.

1 answer

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

You can do something like put a bunch of bricks in a folder in the map and move them around to where you'd want players to spawn. Name the folder spawns, then loop through players and teleport them to one of those randomly. With this, you wouldn't need to do anything when the players die, as they'll re-spawn back to the only roblox spawn locations that should be in the game, which are in the lobby.

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")

while true do
    -- Intermission
    for i = 15,0,-1 do
        status.Value = "Intermission: "..i
        wait(1)
    end
    status.Value = "Game in progress.."
    local map = game.ServerStorage.RockyLands
    local cloned = map:Clone()
    local spawns = cloned['spawns']:GetChildren()
    cloned.Parent = game.Workspace

    for i,v in pairs(game.Players:GetPlayers()) do 
        local rand = spawns[math.random(#spawns)]
        if v.Character then 
            v.Character:MoveTo(rand.Position)
        end
    end

    wait(15)
    for i,v in pairs(game.Players:GetPlayers()) do 
        if v.Character then 
            v:LoadCharacter()
        end
    end
    cloned:Destroy()
    status.Value = "Round over!"
end
Ad

Answer this question