skelly = script.Parent.Parent:WaitForChild("Skelly"):GetChildren() for i, v in pairs(skelly) do v.Transparency = 0 -- This works end skelly.Parent:Destroy() -- attempt to index nil with 'Destroy'
I know that I could just make a different variable, but I want to learn something new. Is it possible to destroy the Skelly model with only that variable?
skelly = script.Parent.Parent:WaitForChild("Skelly"):GetChildren() for i, v in pairs(skelly) do v.Transparency = 0 v.Parent:Destroy() end
this should work and this:
skelly = script.Parent.Parent:WaitForChild("Skelly"):GetChildren() for i, v in pairs(skelly) do v.Transparency = 0 _G.SKELLY = v.Parent end _G.SKELLY:Destroy()