Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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!

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() mudathir2007 157 — 5y
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!!!!! Mast3rStRix 43 — 5y
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 starmaq 1290 — 5y

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago

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

0
Thanks a lot!!! In order to save the map in serverstorage do i copy the models in there or? sorry im new.. Mast3rStRix 43 — 5y
0
Oh also how would i delete the old map using the script in my question? Mast3rStRix 43 — 5y
Ad

Answer this question