What do you want to achieve?
i want it so every child from tower.Stats.Level.Tower goes outside tower than back in after everything inside tower gets deleted
What solutions have you tried so far?
I tried changing the location of where it would go but its still locked for some reason
local clean = true
local tower = script.Parent.Parent.Tower.Value
local towername = script.Parent.Parent.TowerNameV.Value
script.Parent.MouseButton1Click:Connect(function()
local tower = script.Parent.Parent.Tower.Value
if tower.Stats.Level:FindFirstChild("Tower") then
tower.Stats.Level.Tower.HumanoidRootPart.CFrame -= Vector3.new(0,10000,0)
for i,v in pairs(tower.Stats.Level.Tower:GetChildren()) do
v.Parent = game.Workspace
if clean == true then
clean = false
for i,v in pairs(tower:GetChildren()) do
v:Destroy()
end
end
v.Parent = tower.Parent
end
script.Parent.Parent.Parent.Parent.Parent.TowerUpgade:Fire(tower,towername)
end
end)
You’ve called v:Destroy() on all of the towers’ children and then try to call v.Parent = tower.Parent on an instance in tower.Stats.Level.Tower afterwards, something descendant of a child of tower. You’ve destroyed the instance so its been handed to the garbage collector. Its parent is set to NULL and is locked as its about to/has already been deallocated from memory.
Once you destroy an instance you should no longer reference it. Is it necessary you destroy the tower while still operating on it?