I'm creating a script where it cycles through maps and moves them from ServerStorage to Workspace, but when I move the player to the new map, they just fall through because it hasn't loaded yet.
while true do wait() while game.Players.NumPlayers < 3 do wait() end local MapRange = math.random(1, 3) local CityMap = game.ServerStorage.CityMap local ParkMap = game.ServerStorage.ParkMap local WarehouseMap = game.ServerStorage.WarehouseMap wait(5) if MapRange == 1 then script.gameInProg.Value = true local model = CityMap:Clone() model.Parent = game.Workspace print("loading map") child = #CityMap:GetChildren() repeat wait() until #model:GetChildren() == child print("done") teleportIntoMap(model) while script.gameInProg.Value do wait() end wait(10) model:Destroy() script.gameInProg.Value = false elseif MapRange == 2 then script.gameInProg.Value = true local model = ParkMap:Clone() model.Parent = game.Workspace print("loading map") child = #ParkMap:GetChildren() repeat wait() until #model:GetChildren() == child print("done") while script.gameInProg.Value do wait() end wait(10) model:Destroy() script.gameInProg.Value = false elseif MapRange == 3 then script.gameInProg.Value = true local model = WarehouseMap:Clone() model.Parent = game.Workspace print("loading map") child = #WarehouseMap:GetChildren() repeat wait() until #model:GetChildren() == child print("done") teleportIntoMap(model) while script.gameInProg.Value do wait() end wait(10) model:Destroy() script.gameInProg.Value = false end end
Here's my script so far(not including the teleportIntoMap function because that isn't important. Right now I tried waiting for the children of the old and new model to match, but it just waits forever. Anyone got a way to wait until the model is completely moved? Thanks.
Well, you could do
game.Workspace:WaitForChild("Model Name Here")
Basically, it's waiting for the child to be in the workspace if that makes any sense at all.