Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
14dark14 167
4 years ago
Edited 4 years ago
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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago
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()
Ad

Answer this question