I’m currently making a tool and trying to integrate it with selection boxes, but I’m stumped.
I’m trying to add a feature, to where when you hover over someone’s HumanoidRootPart a selection box appears, but I don’t know how to go about doing it, as in, I don’t know a good way to detect whether the user’s mouse is hovering over the part.
Check out the functions Camera:ViewportPointToRay() and Camera:ScreenPointToRay(). These return a ray with origin and direction property. You can use it in a new Ray then multiply direction by how far the camera can go to.
InputObjects have a position so you can use UserInputService then use an InputChanged connected function to use the camera functions with the InputObject position X and Y value like this:
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
-- Fired when the player moves their mouse
mouse.Move:connect(function()
if mouse.Target ~= nil then
if mouse.Target.Name == "HumanoidRootPart" then
-- Show selection box
else
-- Hide selection box
end
end
end)