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

How do I check if 2 parts parents are the same?

Asked by 4 years ago

I have tried

if hit.Parent ~= child --[[i have defined this value]] then
    --code
end
0
Please explain you question properly. Soban06 410 — 4y
0
for example a part touches a part. how do i check if the 2 parts parents are the same? poop07393cfhi3n2222 4 — 4y

2 answers

Log in to vote
0
Answered by
Soban06 410 Moderation Voter
4 years ago

Do it something like this:

Part.Touched:Connect(function(hit)

if Part.Parent == hit.Parent then
    -- We are saying that if the part's parent is equal to the parent of the item that hitted the part.
end

end)

If you have any questions, I will definitely help.

0
If that doesn't work try 'if Part.Parent == hit.Parent.Parent then' IncredibleTeamAidan 104 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

There are multiple ways to do this.
1:

if hit.Parent == Part.Parent then
-- code here

2:

if hit.Parent:FindFirstChild("Part") then
-- code here

Answer this question