Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to target Mouse without using a function? [closed]

Asked by
emite1000 335 Moderation Voter
10 years ago

I'm trying to target the Mouse object and (due to the wiki being in the middle of API renovations) the only way I could find to target the mouse was with this:

script.Parent.Equipped:connect(function(mouse)
    mouse.Button1Down:connect(function()

Now I was wondering if there is a way to target straight to the mouse without having to go through all that function mumbo-jumbo. Is there a hierarchy to get to it, or do you have to use a function?

Locked by adark, 2eggnog, and Shawnyg

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
2
Answered by
2eggnog 981 Moderation Voter
10 years ago

Yes, here's how you do it:

mouse = game.Players.LocalPlayer:GetMouse()

GetMouse() returns a mouse object, which you can use like normal. Running this in any local script will work; it does not have to be in a tool or hopperbin.

1
Keep in mind that this comes with one caveat: you can't set the mouse icon using the PlayerMouse object returned by GetMouse, you still have to use a Tool or Hopperbin to do that. adark 5487 — 10y
Ad