Why does it keep saying my mouse is nil when I already defined it? (Filtering Enabled)
Asked by
7 years ago Edited 7 years ago
I enabled Filtering Enabled so I'm adding RemoteEvents and such.
I added a function in my local script so that when I click, it fires the server. I then added the mouse as an argument in the FireServer() function.
1 | player = game.Players.LocalPlayer |
2 | mouse = player:GetMouse() |
4 | rep = game:GetService( 'ReplicatedStorage' ) |
5 | reme = rep:WaitForChild( 'RemoteEvent' ) |
7 | mouse.Button 1 Down:connect( function () |
I wanted it to print "hello" when it clicks on the baseplate so I wrote this in the server script
(The server script's name is "firer")
1 | rep = game:GetService( 'ReplicatedStorage' ) |
2 | reme = rep:WaitForChild( 'RemoteEvent' ) |
4 | reme.OnServerEvent:connect( function (player, mouse) |
5 | if mouse.Target = = workspace.Baseplate then |
For whatever reason, it keeps on erroring and saying
15:11:09.355 - ServerScriptService.firer:5: attempt to index local 'mouse' (a nil value)
Sorry if my script doesn't make much sense and the mistake is obvious. This is one of my first times working with FE.
Edit since people say it works:
It also works for me when I play, but when I use the client and server test (F7), it says mouse is nil