Hello, How could I make the map reset or regenerate after some time is up or when the game ends so that a new one can begin?
I am tryng to understand the clone() function where it would delete the map and it would generate the cloned one but i cant really understand it.
I need to reset the models as some of them the player can remove by touching them using Remove()
also i found this script which could be helpful:
currentMap = nil function Regenerate() if currentMap then currentMap:destroy() end currentMap = game.ServerStorage.YourMap:clone() currentMap.Parent = workspace end Regenerate()
Thanks for your time!
This is how :Clone()
works, let's say you have a part inside of workspace for an example
local part = game.Workspace.Part --this our part local clonedPart = part:Clone() -- Attention here clonedPart.Parent = game.Workspace
You see that part where we used :Clone(), what we did is set the "clonedPart" variable to the clone of that part. So we cloned that part and set to clonedPart, so you can think of the "clonedPart" variable as our cloned part now. You can see that we also have to set the parent of clonedPart, if we don't the clone doesn't actually show up.
If you were to do this
--there is no difference between putting game.Workspace.Part in a variable or using it like that game.Workspace.Part:Clone()
You'd think that this makes a copy of the part and puts it in workspace, no it doesn't work like that.
So now if you wanted to make your map appear whenever you want, just have it in your ServerStorage (to store it there since it's not needed until a round starts, this is waht ServerStorage is for).