So I’m casting a Ray to detect clicks on character body parts, as the mouse automatically filters those:
local clickedPart = workspace:FindPartOnRay( Ray.new( camera.CFrame.Position, mouse.Hit.Position ) )
But something strange happens: when I click on parts of my character, while looking at it from such an angle that the only thing behind the character is the skybox, and then I print the “clickedPart”, it prints the names of the parts correctly; however, if I look at my character from such an angle that the baseplate is behind it, I always get “nil” printed.
This doesn’t make much sense to me, as not even Baseplate gets printed.
Does anyone have an idea?
If you’re trying to determine if the player has their mouse on a body part on their character, you could try the following code:
local RANGE = 20
local mouse = game.Players.LocalPlayer:GetMouse()
local ray = Ray.new(mouse.UnitRay.Origin, mouse.UnitRay.Direction*RANGE)
local hit = workspace:FindPartOnRay(ray)
if hit then
print(hit.Name)
end
Here’s what I want you to do make a part in front of the character and then try if it works that means there’s some other issue, but if it still doesn’t then it has something to do with the camera, we can work our way up from there.