Hello I am making a game that spawns a random map each round, and when a player reaches the end of the map, they get teleported to the center of the lobby.
In the end of the round, I want the players who didn’t complete the map to get teleported to the center of the lobby. However, it is teleporting all players to the center of the lobby when the round ends…
This is the teleport part of the script:
–Teleport back to lobby
for _, Player in pairs(Players:GetChildren())do
if Player.Character and Player.Character:FindFirstChild('Humanoid') then
Player.Character.HumanoidRootPart.CFrame = game.Workspace.Lobby.SpawnLocation.CFrame
end
end
Can someone help me? I just want the players who DIDN’T complete the map to be teleported to the center of the lobby.
I want the players who already completed the map to be able to stay in the corners of the lobby, etc, not the center.
Here is the full script I’m using:
ServerStorage = game:GetService(“ServerStorage”)
ReplicatedStorage = game:GetService(“ReplicatedStorage”)
Players = game:GetService(“Players”)
Maps = ServerStorage:WaitForChild(‘Maps’):GetChildren()
Status = ReplicatedStorage:WaitForChild(‘Status’)
while true do
--Intermission
local Countdown = 10 -- ten second intermission, make this as long as you want
repeat wait(1)
Countdown = Countdown - 1
Status.Value = 'Intermission : '..Countdown
until Countdown <= 0
--Choose the map.
Status.Value = 'Choosing Map...'
local ChosenMap = Maps[math.random(1, #Maps)]:Clone()
local Spawns = ChosenMap:FindFirstChild('Spawns'):GetChildren()
local RandomSpawn = Spawns[math.random(1, #Spawns)]
wait(5) -- little pause, make this as long as you want
ChosenMap.Parent = workspace
Status.Value = 'Next Map Is: '
wait(2) -- little pause, make this as long as you want
Status.Value = ChosenMap.Name
wait(2) -- little pause, make this as long as you want
--teleport the players
for _, Player in pairs(Players:GetChildren())do
if Player.Character and Player.Character:FindFirstChild('Humanoid') then
Player.Character.HumanoidRootPart.CFrame = RandomSpawn.CFrame
end
end
Countdown = 15 -- Game Time, make this as long as you want.
repeat wait(1)
Countdown = Countdown - 1
Status.Value = 'Time left : '..Countdown
until Countdown <= 0
--Teleport back to lobby
for _, Player in pairs(Players:GetChildren())do
if Player.Character and Player.Character:FindFirstChild('Humanoid') then
Player.Character.HumanoidRootPart.CFrame = game.Workspace.Lobby.SpawnLocation.CFrame
end
end
ChosenMap:Destroy()
end