So i'm making a game with houses that regenerate once destroyed, the first regeneration works perfectly but dose not repeat itself after that.
Here's my code:
object = game.Workspace.Map
if (object ~= nil) and (object ~= game.Workspace) then
model = object
messageText = "Regenerating Map"
message = Instance.new("Message")
message.Text = messageText
backup = model:clone() -- backup model
waitTime = 3 -- How long it takes until new regen
wait(math.random(0, waitTime))
while true do
wait(waitTime) -- Regen wait time
message.Parent = game.Workspace
model:remove()
wait(3) -- how long the regen msg stays
message:Destroy()
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
message.Parent = nil
end
end
I hope there's a simple solution to this :)

9 comments
:remove() isn't a thing and :Remove() is depricated.
Should i replace them with :Destroy()?
it still does the same thing, the map is not regenerating more than one time.
No it does not.
:remove and :Remove only set an object's Parent to nil, and Destroy does the same, but also locks the parent property (it cannot be reparent es unlike :remove), and prepares the object for garbage collection. :This article here explains this: https://scriptinghelpers.org/blog/do-you-have-zombies-in-your-code
wait, game.Workspace.Map is a folder filled with models. dose this change anything?
Change :remove() to :Destroy() and :clone() to :Clone()
Ok, ill try
It dose the first part of the proccess by 'destroying' the map, but the regeneration message just stays and the map dose not come back.