I don't want the previous model deleted once the regen button is touched.
--Person299
--Put the objects you want regenned in the model, if the object's parent is changed it will not be deleted when the button is pushed again.
debounce = false
regen = {}
last = {}
for a,b in ipairs(script.Parent.Parent:GetChildren()) do
if b ~= script.Parent then
table.insert(regen,b:clone())
table.insert(last,b)
end end
script.Parent.Touched:connect(function(hit)
if hit.Parent ~= nil then
if game.Players:playerFromCharacter(hit.Parent) ~= nil and debounce == false then
debounce = true
for a,b in ipairs(last) do
if b.Parent == script.Parent.Parent then
b:remove()
end end
last = {}
for a,b in ipairs(regen) do
local c = b:clone()
table.insert(last,c)
c.Parent = script.Parent.Parent
pcall(function() c:MakeJoints() end)
end
script.Parent.BrickColor = BrickColor.new(26)
wait(2)
script.Parent.BrickColor = BrickColor.new(104)
debounce = false
end end end) |