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

Why isn't the Touch Detection Detecting Parts?

What I mean by "Touch Detection" is when something touches another thing. Say we have this script:

local Part = (Part)

Part.Touched:Connect(function(hit)

 print(hit)

end)

When a Humanoid touches the part, it prints the parts of the Humanoid. When another part touches it, that doesn't happen. Why? How do I fix it?

2 answers

✓ Accepted answer

I've run the script myself and can confirm the programming itself is fine. That said, the .Touched event is only run when a collision occurs. If the objects seem to be touching but don't class as a collision, that's likely the issue you're experiencing. For example, creating a part and manipulating CFrames to make them overlap doesn't provide a collision, as both parts are anchored and immovable, however, throwing a tool which is not anchored on to the part will cause a collision. Put more simply, the event doesn't register the touching of anchored parts.

2 comments

0

Thanks! I'll try it out

0

It worked, sorry I didn't get back sooner. As soon as it worked I moved onto the next part of my game xD

You got to make it detect if its a part when its touched so

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Part") then
		print(hit)
	end
end)

1 comment

0

That wouldn't have helped because it wasn't detecting a collision in the first place. All you're doing is debugging, which is something I already did lol. That's why I know there's a problem

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