Trouble getting if a part touched a certain part

Im tryna get this part
image
to detect if its touching this part
image

local touched = Object.PrimaryPart.Touched:Connect(function(hit)
						print(hit.Name)
					end)

this what i got but no output
both parts have cancollide off. itll detect if i walk into it though.

Maybe more like this. Wherever Object is.

local Object = workspace:WaitForChild("Object").PrimaryPart
Object.Touched:Connect(function(hit)
     --print(hit.Parent.Name)	
       print(hit.Name)
end)

yeah still nothing.

PlacementEvent.OnServerEvent:Connect(function(Player,PreviewObject,ObjectCFrame)

local Object = ObjectFolder:FindFirstChild(PreviewObject):Clone()
	Object:SetPrimaryPartCFrame(ObjectCFrame)
	Object.Parent = game.Workspace
	local pu = 3
	local db = true
	Object.PrimaryPart.Touched:Connect(function(hit)
		if db then db = false	

			print(hit.Name)

			task.wait(pu)
			db = true
		end
	end)

end)

Drop down to the simple one if you’re adding all that. Not part of the question you asked.
Who knows if what I posted will work with added code.

Can you tell me what this might be used for? Depending on what your doing, you might be able to use :GetTouchingParts() or something like that.

Are you trying to get the part to touch an another part?

While I did some problem-solving and testing, I have solved the problem and I’ll give you the script I did.
In Roblox Studio, I added Part A and B but this is an example.
Part A needs to touch the Part B so I added a script inside ‘Part B’.
If Part B detects a part which named ‘Part A’, this will bring out an output.

This is what I did in the script but this is inside ‘PartB’:

local part = script.Parent
part.Touched:Connect(function(hit)
	if hit.Name == "PartA" then
		print("TOUCHED")
	else
		print("NOT TOUCHED")
	end
end)

I found a solution after digging a bit deeper in the dev forum and other sites

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.