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

Mouse Returning Nil When Passed Through RemoteEvent? [Solved]

Asked by
Laxely 3
6 years ago
Edited by OldPalHappy 6 years ago

Hi, I have a local script in the StarterPack with a server script with a remote in it. The problem is that I'm trying to pass the mouse argument to the remote and it keeps returning nil.

-- Server Script
script.Script.OnServerEvent:connect(function(p,m)


-- Local Script
m = p:GetMouse()
remote:FireServer(m)

This is probably really simple but I just can't find it out.

0
The server can't access the mouse object. Pyrondon 2089 — 6y
0
I know that's why I'm trying to pass it as an argument from the local script to the server script Laxely 3 — 6y
0
That would mean the server would be accessing the mouse object, which it can't. 1waffle1 2908 — 6y
0
so how would i fix it? Laxely 3 — 6y
View all comments (2 more)
0
You can't. Do the stuff that requires the mouse on the client. OldPalHappy 1477 — 6y
0
ohh ok thanks Laxely 3 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

The mouse is client-side. Whenever you try to pass something through a RemoteEvent/Function that only exists on the server and not the client (or vice versa), it is replaced with nil. (In this case, the client knows what the mouse is, but the server does not.)

If the server needs something regarding the mouse (ex. what the mouse is pointing at), simply pass that information to the server instead of the mouse.

Ad

Answer this question