Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 27 May 2015 03:32 PM |
| If I just clone a map into workspace, my main script will continue executing lines under the line that clones, regardless if the map is completely loaded or not. I was thinking a foolproof way to get around this was to make it so the script waits for a child in the map that loads last before it executes the rest of the code, like Map:WaitForChild("DoneLoading") |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 03:36 PM |
Just use a for loop.
for i, v in pairs(Map:GetChildren()) do v.Parent = workspace end
--Other things.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 27 May 2015 03:36 PM |
| No, because then it won't stay grouped and I will have a hard time removing it. |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 May 2015 03:41 PM |
| put the parts of the map in a designated empty model inside of workspace called "MapHolder" or something like that. |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 03:45 PM |
Did using :WaitForChild() not work?
- “My dear, here we must run as fast as we can, just to stay in place. And if you wish to go anywhere you must run twice as fast as that.” |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 May 2015 03:53 PM |
so put an empty model named MapHolder inside of workspace, and do some like this:
local randomMap = maps[math.random(1, #maps)]
function loadMap(map) for i, v in pairs(map:GetChildren()) do v.Parent = game.Workspace.MapHolder wait() end end
-- code
loadMap(randomMap) -- stuff after map has loaded
when you want to clear the map, just loop through map holder and destroy everything.
for i, v in pairs(game.Workspace.MapHolder:GetChildren()) do v:Destroy() end
and that should yield the thread until the map is fully loaded i think
i didn't test this |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 04:00 PM |
I just gave you the barebones dude. You need to add the meat. :P
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|