Touch event only affected by Humanoid or Torso

How would I come to make a touch event only being affected by Humanoid or Torso?
The purpose is to fire a remoteevent to be fired once.

local part = script.Parent
local re = part.RemoteEvent

local function oT(part)
	if part.Parent:FindFirstChild("Humanoid") then
		local player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
		re:FireClient(player)
		print("In")
	end
end

local function oTE(part)
	print("Moved")
end

part.Touched:Connect(oT) -- onTOuch
part.TouchEnded:Connect(oTE) -- onTouchEnded
1 Like

try checking if the part’s name is torso or HumanoidRootPart as well as your normal checks.

How would I come to check if its either a torso or a humanoidrootpart?

For R6 avatars.

if part.Name == "Torso" or part.Name == "HumanoidRootPart" then
if part.Name == "UpperTorso" or part.Name == "LowerTorso" then

This would be required for R15 avatars.

1 Like
local part = script.Parent
local re = part.RemoteEvent

local function oT(part)
	if part.Parent:FindFirstChild("Humanoid") and part.Name == "HumanoidRootPart" then
	--                                            ^^ check here
		local player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
		re:FireClient(player)
		print("In")
	end
end

local function oTE(part)
	print("Moved")
end

part.Touched:Connect(oT) -- onTOuch
part.TouchEnded:Connect(oTE) -- onTouchEnded
1 Like

Thank you both for helping!
Both of your solutions worked.