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

Is there a way to access the mouse through a Remote Function?

Asked by
xEiffel 280 Moderation Voter
6 years ago

Hi, I asked a question earlier through wondering why my script isn't working that's getting fired from a Remote Function that accesses the mouse object through the Local Script, then transfers it to the script. But It doesn't work, It just says it's nil. Does anyone know a way to avoid this, or would a Remote Event work instead? Thanks.

2 answers

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
6 years ago
Edited 6 years ago

Nil mouse is intentional because it's simply bad networking practice. Try to simply send a dictionary of the mouse properties if you need them so bad.

{Hit=mouse.Hit,Target=mouse.Target,X=mouse.X,Y=mouse.Y}

Plus anything else you want of course

0
He's asking for an access through a RemoteFunction, not a RemoteEvent magicguy78942 238 — 6y
0
??? cabbler 1942 — 6y
0
magicguy, it makes literally no difference as either way you prefer will make no difference to the fact that the server has no access to the mouse itself. M39a9am3R 3210 — 6y
Ad
Log in to vote
-2
Answered by 6 years ago

If you want to send the request from the player's mouse target to the server then you must make sure from the Local script that it is a real object, and not nil

Here's an example script:

if mouse.Target then
    RemoteFunction:InvokeServer(mouse.Target)
end

--Or you could use this!

if mouse.Target ~= nil then
    RemoteFunction:InvokeServer(mouse.Target)
end

Answer this question