How can we generate a map, part by part using wait()?
I'm actually in the scripting part of a Horror game, but I don't really know how can we generate map parts one after another like, every 5 seconds.
Thanks for answering! :D
How can we generate a map, part by part using wait()?
I'm actually in the scripting part of a Horror game, but I don't really know how can we generate map parts one after another like, every 5 seconds.
Thanks for answering! :D
Maps should be stored in ServerStorage.
When generating a map, you should clone it.
local Map = game.ServerStorage:FindFirstChild("Map")
local ClonedMap = Map:Clone()
And since you want to move the model part by part, you want to make a new destination model.
local NewMapModel = Instance.new("Model",game.Workspace)
now, to move the parts from the Cloned Model to the NewMapModel, you should use a pairs loop.
for i,v in pairs (ClonedMap:GetChildren()) do
v.Parent = NewMapModel
wait(5)
end
Explanation of what we've just done:
ClonedMap:GetChildren() returns a table, of the descendants(Parts inside) of ClonedMap.
for i,v in pairs goes through each Instance in the table, in this case, Parts inside the model. the i is unimportant in this situation.
However, v is the part.
in Line 2, we changed v(Part inside the model) Parent to the New Model.
Then in Line 3 we waited 5 seconds before it moved on to the next part in the table.
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Will it work if I'll put the map in Lighting and change the destination?
In the script?
Sure I guess. ServerStorage is better. But your choice.
Ok thanks!