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

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

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

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

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