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
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