How to detect if a player is on top of a Part using `.Touched`

Is there a way using

Instance.Touched:Connect(function() end)

Can I detect if a players HumanoidRootPart is above the part.

Yes, you can. You just need to create an argument so you can know additional things about the touching part.

Instance.Touched:Connect(function(argm)
if argm.Parent:FindFirstChild("Humanoid") then
print("Player found!")
end
end)

Not entirely what I am asking for.

You could rename “Humanoid” to “HumanoidRootPart” if you really need to detect it.

Use RayCasting.

Fire a ray downwards from the HumanoidRootPart when a player touches the part. Check if the ray’s result.Instance is the part.

1 Like

Can I detect if a players HumanoidRootPart is above the part.

I will try this.

Hopefully it works.

You would need to use dot products in that case then.
Something like this:

local Dot = script.Parent.CFrame.LookVector:Dot(argm.CFrame.LookVector)

I’m not an expert at this so if it doesn’t work then try playing around changing the LookVector to another vector.

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