I need to be able to click on a visible attachment in my game, and I’ve decided to use a raycast for it.
My code:
local function MouseSelectPreview()
local mouseLocation = UserInputService:GetMouseLocation()
local unitRay = camera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
local cast = workspace:Raycast(unitRay.Origin, unitRay.Direction * 1000, castParams)
if cast then
print(cast.Instance) -- I expect to see the attachment here, but instead I see whatever is behind the attachment
end
end
RunService:BindToRenderStep("MouseSelect", Enum.RenderPriority.Camera.Value,
Hi. Attachments dont have collisions and aren’t able to be hit by raycasts. Maybe place another (invisible?) part at the same position as the attachment, with canCollide set to false and canTouch set to true.
yeah, that’s what I was thinking too. Which means I need to complicate my hierarchy, but that’s okay for the sake of it working (I’ll need weld constraints and other things). If I don’t get a solution in the next 10 minutes, I’ll mark your post as the solution