Hello. I’m working on a game where it loads maps and you teleport to them. I have two maps for testing. When the script selects the map, only one of them actually teleports me onto it and starts. The other one says the name of the map selected and loads it, and then it just gets stuck there. I do not know how to fix it. Please help.
Image of me being teleported into the working map.
Image of it freezing and not teleporting me.
The script.
– Variables
local Lobby = game.Workspace.Lobby
local Maps = game.ReplicatedStorage.Maps:GetChildren()
local Status = game.ReplicatedStorage.Status
– Game Loop
while true do
-- Intermission
for i = 10, 0, -1 do
Status.Value = "Intermission: "..i
task.wait(1)
end
-- Map Selector
local ChosenMap = Maps[math.random(1, #Maps)]
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = game.Workspace
Status.Value = "Map: "..ClonedMap.Name
task.wait(3)
-- Teleports to Map
for i, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if Character then
local HumanoidRootPart = Character.HumanoidRootPart
HumanoidRootPart.CFrame = ClonedMap.TeleportPoint.CFrame
end
end
-- Game Time
for i = 10, 0, -1 do
Status.Value = "Game: "..i
task.wait(1)
end
-- Teleports to Lobby
for i, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if Character then
local HumanoidRootPart = Character.HumanoidRootPart
HumanoidRootPart.CFrame = Lobby.TeleportPoint.CFrame
end
end
-- Destroys Map
ClonedMap:Destroy()
end