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

Is it possible to access the mouse within a single server script?

Asked by 10 years ago

If so, how would you do it?

3 answers

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Script objects inside of Tool or Hopperbins can use the Equipped and Selected (respectively) events and get access to Mouse objects.

However, this isn't an elegant way to do it, nor do I believe it's a "true" solution because of how I believe it to be implemented from a technical perspective.


There is no direct way to get a mouse object on a server script in normal conditions.

The best you can do is use a LocalScript to repeatedly broadcast the information from the LocalPlayer's Mouse (obtained via GetMouse).

The .Target, .X, .Y, and .Hit.p are the relevant fields that could be used. Since the mouse is only meaningfully read-only, this isn't so bad of a set-up (since both the LocalScript and ServerScript remain pretty simple)

Ad
Log in to vote
0
Answered by
Discern 1007 Moderation Voter
10 years ago

A LocalScript is required to get a player's mouse. It's impossible to get it through a server script.

0
I've seen people do it with a server script though; so I'm just really confused. hievery1 70 — 10y
0
Perhaps they've used a RemoteEvent? But even then, that would be useless. Redbullusa 1580 — 10y
Log in to vote
0
Answered by
iLegitus 130
10 years ago

Try this : (In your server script)(Workspace)

for i,v in pairs(game.Players:GetPlayers()) do 
    pcall(function() 
    v:GetMouse() 
-- v,Is the Player (This gets the Player's Mouse from a server script)
    end) 
    end

Tell me if it didnt work,Ill try helping out again.

Answer this question