Help with touch event

  1. What do you want to achieve? I want to make it so when a special part got touched it will do a thing/print

  2. What is the issue? How would I make so if only the other part got touched by a special part it will print

  3. What solutions have you tried so far? I tried to get the local part and then put it in

Example
local part = script.Parent
local part2 = game.Workspace.Part234234

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild(part2) then
		print("Touched")
	end
	
	
end)
1 Like

You sure the path is correct? From what I understand you’re finding if the 1st part is the parent of the second, but on the part2 variable you state that it’s parented to the workspace.

Path or Part? I got confused if you have any idea can you explain?

I meant if you’re defining the part you’re trying to find correctly. Also, could you tell me exactly what you’re doing?

I got the local part I think it is a correctly way. I’m trying to do so if part got touched by a special part it will print and if part will touch not special part it will not print

You could put this in a ServerScript inside the part you want touched:

local trigger = script.Parent
local part2 = --your part here!!
trigger.Touched:Connect(function(hit))
   if hit.Name == part2 or hit == part2 then
      print("Special part touched!")
   end
end)

Edit: I think this should be working.

That should work but do if hit == part2 (maybe hit.Name )

Oh he’s trying to check if a part touches another part?

1 Like

It is working but you need to change if hit.Name == "(Part in the workpace)" then

1 Like