This is a partial part of a script that selects a map randomly, says the map name, and spawns everyone there. It is a copy of a script I have in another game. For some reason I keep getting the same message "Spawn is not a property of Model" (line 18) I have a few Parts
in a Model
named Spawns(Via the spawns), thatModel
is in another Model
named Test(Via the map) with parts of the map inside that. So it sort of looks like game.Lighting.Minigames.Test.Spawns.Part
minigames = game.Lighting.Minigames:GetChildren() if game.Players.NumPlayers > 1 then for _,v in pairs(game.Players:GetChildren()) do v.PlayerGui.Ament.TextLabel.Text = "Choosing Game..." end wait(3) ranGame = math.random(1, #minigames) gameChosen = minigames[ranGame] for _,v in pairs(game.Players:GetChildren()) do v.PlayerGui.Ament.TextLabel.Text = "Minigame Chosen: " .. gameChosen.Name end wait(3) gameChosenClone = gameChosen:Clone() gameChosenClone.Parent = game.Workspace wait(3) --Spawning 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 end
When you clone a large map to workspace, it might take more than 3 seconds to load the entire thing. If it's still loading after three seconds and you call something that hasn't loaded yet, it won't work! Solution: Use :WaitForChild().
:WaitForChild() will yield the script until an object with the name that is the string inside the parameters. Of course, if it'll go on forever if it never happens, so make sure that you get the name correct! It'll be case sensitive!
--Instead of spawns = gameChosenClone.Spawns:GetChildren() --Do this spawns = gameChosenClone:WaitForChild("Spawns"):GetChildren()
I would've added tabs to my paragraphs, but every time I did, it changed it into a Code Block...