Anyone know what’s causing this weird regeneration glitch? (SOLVED)

So I have been working on making a blocky red van I made regenerate after a few seconds I finally made it work but for some reason after a few times it starts going really weird (see video the whole way to understand)


as you can see it starts out fine but then it’s like it clones itself one stud behind and just keeps doing it till the game crashes sorry for explaining it so badly it’s not easy to explain :sweat_smile:

Here’s the script I used to make it regenerate

(here’s it so it’s easy to copy paste)
local model = script.Parent

backup = model:clone()

while true do
wait(8)

model:remove()

model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()

end

Thanks in advance to the people who spent time to help me means a lot :relaxed:

You are cloning the script as well within the backup. This causes an infinite loop and crashes eventually.

To solve it delete the script that is being cloned.

model.Regen:Destroy()

Then parent it.
Model.Parent = blabla

1 Like

why do you repeatedly spawn? why cant you just spawn it whenever the van disapear? also i cant see the video for some reason

local model = script.Parent

while task.wait() do
	local modelClone = model:clone()
	modelClone.Parent = game.Workspace
	task.wait(8)
	modelClone:Destroy()
end

Alright cool I will try that thanks

what should I put where you have “blabla?”

Because I am not brainy and don’t know how to do that I am a noob scripter



hmm that scripted didn’t work I am not sure why?
also I changed scriot to script

local model = script.Parent

while task.wait() do
	local modelClone = model:clone()
	modelClone.Parent = game.Workspace
	task.wait(8)
	modelClone:Destroy()
end

You just made same script, but even typed it wrong.

Thanks for noticing that & the script was changed to destroy the cloned model instead.

Sorry still doesn’t seem to work :frowning: thanks for helping again tho!

Mind explaining what you want the script to do? I was just fixing the code you had provided.

all I want it to do is just regen properly and not crash and not do this


for some reason all the scripts I and you have made have kinda done the same thing

the first 2 times in the video it goes past is what I want it to do

local model = script.Parent
local backup = model:Clone()

while task.wait() do
	local backupClone = model:Clone()
	backupClone.Parent = game.Workspace
	task.wait(8)
	backupClone:Destroy()
end

Make sure there are no other scripts that could be interfering.