Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to reset the map for when a new round begins?

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!

3 comments

1

Just to let you know, use :Destroy() since Remove() is deprecated. In that script, you should use :Destroy(), not :destroy() switch to :Clone() and not :clone()

0

Oh my.. you have no idea how much your comment helped me I couldnt find what was wrong in my previous script but this was the problem! (in the removing models script) Thanks a ton!!!!!

0

yeah as mudathir said, to remove the copied map use :Destroy() and to put stuff in server storage just drag it there, like you would anywhere else

1 answer

✓ Accepted answer

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).

2 comments

0

Thanks a lot!!! In order to save the map in serverstorage do i copy the models in there or? sorry im new..

0

Oh also how would i delete the old map using the script in my question?

This discussion is preserved as it was. New answers, comments, and votes are closed.