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

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

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

✓ Accepted answer

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)

4 comments

0

inconstant chance of coming ( i have tried it before but forgot to add it) https://imgur.com/a/58Mgvws

0

inconsistent e.e spelling and grammer

0

Edited

0

Thanks :D

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