Hi.
I have a BoolValue that gets set to true when my game starts.
A global script in StarterCharacterScripts (ergo, in all the players) detect when this happens, finds the map that was automatically generated by another script and teleports the player to a part included named PlaceToStart. And before you ask, all of the maps that could be generated contains this part, at least that's what I found, and the part was anchored.
This is the code:
game.Workspace["Special Stuffs"].GameProgress.Changed:Connect(function() -- if the Game Progress has been updated if game.Workspace["Special Stuffs"].GameProgress.Value == true then -- if it is updated to say the game has started script.Parent.CFrame = game.Workspace.Map:FindFirstChildOfClass("Model").PlaceToStart.CFrame -- teleport to this part end end)
but whenever I run it, I get one of these as an error (never all):
21:37:28.814 - Workspace.KicksForTricks56.GameTeleporter:3: attempt to index a nil value 21:42:38.957 - PlaceToStart is not a valid member of Model 21:45:48.891 - CFrame is not a valid member of Model
I tried using :FindFirstChild() and :WaitForChild(). It didn't give me an Infinite yield warning when I did it so I know it acknowledges that it exists, but it still doesn't think it's a vaild member of the map! I am baffled about why this is happening, especially when I check in Explorer and find it that the part still does exist, both in-game (after I get the error) and in editor mode. Does anybody know what is happening?
Models Position can be changed with MoveTo. Not rly sure if this is the best way though.
http://wiki.roblox.com/index.php?title=API:Class/Model/MoveTo
MoveTo is like changing Position on a model
you can also use the primary part's CFrame.
PrimaryPart.CFrame is like useing CFrame on a model