Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

If so, how would you do it?

3 answers

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)

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

2 comments

0

I've seen people do it with a server script though; so I'm just really confused.

0

Perhaps they've used a RemoteEvent? But even then, that would be useless.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.