Help with mouse

how do i do it so whenever the tool is activated then if the players mouse is close to the player (and on them) then it will do something

Well we can’t just spoon feed you scripts, and also can you be a bit more specific please?

Anyways, check out the Developer Hub it will probably help you out!
Also like @Ashqetix said, using a click detector if its a block will work out.


If you are talking about when a players mouse hovers over a part, you can put a click detector in that part. Then using code, you can make it so that when you click that part, it does something.

try to use CFrames with Magnitudes. Tools also have a .Activated function.

ive tried so many methods and they didnt work, i tried using currentcamera and magnitude with the mouse and they didnt work
im trying to make it so if the players mouse is close to the enemy players humanoidrootpart then it will do something

use something like this:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local maxdist = 10 --distance from character

    if (mouse.Hit - player.Character.HumanoidRootPart.CFrame).Magnitude < maxdist then
        --do whatever.

and for a tool, instead of the mouse.Button1Down, use tool.Activated.

it doesnt detect the enemy player

I just gave you an example of how Magnitudes work. Scripting Help is not for full scripts. You can use what I sent and twist it around a bit.

You can use the mouse.Target variable and check if the mouse.Target is equal to a player.

thats not what im trying to do im trying to get the mouse and check if hes close to the enemy player

Well then you could check if the mouse.Target is equal to another player and then determine the magnitude of the mouse.Target from the player.

Edit: The reason it took me so long to reply was becasuse I was gonna reply with some example script but we are not here to provide you scripts. You have to do that on your own.

you realize im not a begginer scripter right

I never said nor implied that. It just seemed like you were requesting a script from the replies

because ive tried so many methods and it doesnt work

Either way you shouldn’t be requesting or expecting fully written scripts in return. We are here simply to provide our knowledge to you on the situation such as explaining possible methods of doing set problem.(Sorry If I sound a bit passive aggressive)