At least I think. Here's the code I'm using
-- I already defined the mouse and player variables and yes I defined the correct ones mouse.Move:connect(function() local part, position = game.Workspace:FindPartOnRay(mouse.UnitRay, player.Character) print(part, position) end)
It always prints nil even when I'm pointing to the Baseplate and gives the position of the Camera which doesn't work either. Is this intended behavior of the UnitRay?
This will work as long as the target is within 500 studs of the camera.
mouse.Move:Connect(function() -- connect is deprecated, use Connect (uppercase C) local mouseray = Ray.new(mouse.UnitRay.Origin,mouse.UnitRay.Direction * 500) local part, position = game.Workspace:FindPartOnRay(mouseray, player.Character) print(part, position) end)