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

What is the easiest way to find if Human touched this part?

I know many ways to check if Humanoid touched a part but What Is the easiest one and the shorter one?

3 comments

0

check if they have a humanoid

0

or you could loop through the players to see if the player's character is the one that touched

0

if hit.Parent:FindFirstChild("Humanoid") and game.Players:FindFirstChild("hit.Parent.Name") then

1 answer

✓ Accepted answer

I always do something like this:

part.Touched:Connect(function(obj)
	local char = obj:FindFirstAncestorOfClass("Model")
	if char and char:FindFirstChildOfClass("Humanoid") then
		--a player touched
	end
end)

Unlike using obj.Parent, this way guarantees that even if the touching part is i.e. a part of an Accessory, the function will still recognise the player.

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