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 3 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 — 3y
0
for example a part touches a part. how do i check if the 2 parts parents are the same? poop07393cfhi3n2222 4 — 3y

2 answers

Log in to vote
0
Answered by
Soban06 410 Moderation Voter
3 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 — 3y
Ad
Log in to vote
0
Answered by 3 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