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

Getting the part that got touched?

Hi! I know it's possible and easy to get what touched a part when calling for a function through Touched, but is it possible to get that part that called the function? That might've been a bit confusing to read but it's the best way I can describe my question

for i,v in pairs(game.Workspace.Cameras.TouchParts:GetChildren()) do
	if v.ClassName == "Part" then
		v.Touched:Connect(TouchedPart)
	end
end

This is my code, it calls the function TouchedPart when any Part in Cameras.TouchParts get touched. I need to know which part was actually touched and called the function. Is there a way to do this within the touched connector? If not, anyone got any ideas for getting that?

1 answer

Maybe inside the function write this?

if TouchedPart.Name == "Part" then
-- write some code here
end

1 comment

0

oops, meant to write TouchedPart.

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