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

How to check if a model is a child of a model?

The question pretty much sums up: How to check if a model is a child of another model, with a server script?

Thanks for the Help!

1 comment

0

you could try if script.Parent.ClassName == "Model"l then...Code...end

1 answer

✓ Accepted answer

You can use the IsA class identifier metamethod. This allows you to pass an Instance through a conditional statement asking to compare it, or it's parent in this case' class type. Virtually, this can act as a form of verifying whether a certain Object is a child, of a specific Instance.

local myModel = workspace.Model

if (myModel.Parent:IsA("Model")) then
    print(myModel.Name.." Is a child of "..myModel.Parent.Name.."!")
end

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