Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I destroy this model? ( get model from children )

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?

1 answer

✓ Accepted answer
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()

This discussion is preserved as it was. New answers, comments, and votes are closed.