Player Mouse Issue

I was writing a script and then realized I may have set up the player’s mouse wrong but everything checks out for me. Am I forgetting something?

image
I’m simply printing the variables to test what I did wrong but the error says:

Workspace.Part.Script:3: attempt to index nil with ‘GetMouse’

Maybe its because Players.LocalPlayer is nil on a Server Script?

Only LocalScripts can get the players mouse.

Even if you had the Player on the server you wouldn’t be able to get the mouse.

1 Like

you cant grab the player from the server, youd have to use a local script

LocalScript:

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local mouse = player:GetMouse()

print(mouse)

image