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

How do I tell if one parts parent is the same as the other?

Asked by 3 years ago

So for example, I have this script:

local model = workspace.Plots["1"].Building

model.ChildAdded:Connect(function()
    for name, child in pairs(model:GetChildren()) do
        child:WaitForChild("Hitbox").Touched:Connect(function(hit)
            if hit.Parent ~= child then
                child:Destroy()
            end
        end)
    end
end)

Basically, it creates a new part and if it is touching that other part it will check if it has the same parent. If it doesn't it will destroy that model.

1 answer

Log in to vote
0
Answered by 3 years ago
local model = workspace.Plots["1"].Building

model.ChildAdded:Connect(function()
    for name, child in pairs(model:GetChildren()) do
        child:WaitForChild("Hitbox").Touched:Connect(function(hit)
            if hit.Parent.Name == child.Parent.Name then
                child:Destroy()
            end
        end)
    end
end)

boop

0
nonononono, dont check the name, check the object instead as he did Gameplayer365247v2 1055 — 3y
0
lemme try that poop07393cfhi3n2222 4 — 3y
Ad

Answer this question