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 :)
function Regen() --Whenever Regen() is activated it will start function 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 end repeat --Always checks to see when to start Regen() wait() object = game.Workspace.Map if (object ~= nil) and (object ~= game.Workspace) then Regen() else wait(15) print("Game in Progress") end until script.Name == "BAD" --If the script name becomes BAD then script will stop checking when to start regen