Hello sentry3, I am here to help you!
When inserting a ClickDetector, we can use it's functions and properties. In this case we will be using MouseHoverEnter and MouseHoverLeave.
So let's begin, shall we?
I am pretty sure getting the Player's mouse that way is out dated, if you really want to grab the player's mouse then you should use UIS. However, to keep our script nice and simple, we'll just be using ClickDetector(s) as they work the same. UIS is much smoother and doesn't place a big cursor in your screen, however; this is better for new scripters.
So, what you want to firstly do is insert a SelectionBox by pressing CTRL-I ( make sure you didn't type a one, but an I ). Double click this asset and it should be in your Workspace. As an example, place this SelectionBox inside of a Dummy Rig. Now if you like, decorate and make changes to your SelectionBox ( thickness, colour, etc ). After this, set it's Visible property to false.
Now insert a ClickDetector inside of your Rig Dummy. Don't edit this at all, unless you know what you're doing. Finally, insert a regular script and let's begin to code!
What we always have to do before we "actually" code is defining variables. We're going to define the Dummy's ClickDetector and name it cd for short. Having variables is cleaner and can be used for later reference.
local cd = script.Parent:WaitForChild("ClickDetector")
Now let's insert our two functions.
cd.MouseHoverEnter:Connect(function()
end)
cd.MouseHoverLeave:Connect(function()
end)
As you can see from viewing the script alone we've made some functions, use the silenced quotes to understand.
Now all we have to do is make the SelectionBox visible and invisible with these functions.
local cd = script.Parent:WaitForChild("ClickDetector")
cd.MouseHoverEnter:Connect(function()
script.Parent:WaitForChild("SelectionBox").Visible = true
end)
cd.MouseHoverLeave:Connect(function()
script.Parent:WaitForChild("SelectionBox").Visible = false
end)
Ta-dah, we have made our script, now if you want the hitbox to be on a player then create a script for whenever a player is added and then make it that it Instance.new's the ClickDetector and SelectionBox into the player!
If you have learnt anything from me, please Accept Answer!