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

How can i find the 'Main' Parent parent of the Part (excluding workplace)?

Asked by 5 years ago
Edited 5 years ago

Hello, I have a Touched function from the server side seeing what the player has Touched. It does work and print's out the exact part what its touching but for my application i have a player and the touched function should return with the players name ( respectively the parent of the part i shall say).

chilli.Touched:Connect(debounce(function(response)
                       if buttonPressed == true then

                          print(response)
                            -- some code here to find the player name from touching the player's part 


                        buttonPressed = false
                      end
                   end))

https://imgur.com/a/eNlwtyG

From the GIF above it should return with the parents name.In my Case its 'Bob'

thanks,

However,replacing the print command with (response.Parent.Name) will sometimes print the name but the chances are slim

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

the Hit parameter only gives you the specific part that touched, to get the thing it's inside of you can use .Parent.

chilli.Touched:Connect(function(Hit)
    if buttonPressed == true and Hit.Parent:FindFirstChild("Humanoid") then
        print(Hit.Parent.Name)
    end
end)
0
inconstant chance of coming ( i have tried it before but forgot to add it) https://imgur.com/a/58Mgvws jack001214 19 — 5y
0
inconsistent e.e spelling and grammer jack001214 19 — 5y
0
Edited mattscy 3725 — 5y
0
Thanks :D jack001214 19 — 5y
Ad

Answer this question