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

How to make players move back to lobby?

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

3 comments

0

Please make an attempt at what you are asking for before simply demanding code or your question will be closed.

0

I did. Do I add the attempt to it also? I'll add now

0

ok done

1 answer

✓ Accepted answer

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

1 comment

0

What does it mean if can't be a model?? Does it have to be a spawnpoint????

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