Roblox 'attempt to index nil with :GetMouse()'

Hello. I am doing a commission for a 6 guns, in each gun’s client script, I wait until game:IsLoaded() is true and then start getting the mouse, etc. But, only in the first gun it doesn’t error, but in the guns after, it errors 'attempt to index nil with :GetMouse()`. Here is the client script (important part):

repeat wait() until game:IsLoaded() == true
local tool = script.Parent;
local isShooting = false;
local userInputService = game:GetService("UserInputService");
local mouse = game.Players.LocalPlayer:GetMouse(); -- Here it errors.
2 Likes

Does this script run on server?

1 Like

No, this is a LocalScript inside the tool.

1 Like

But in that case Localplayer shouldn’t be nil.

1 Like

Wait. I am an idiot, somehow I didn’t notice this was on the serverscript, I have no idea how it got there :joy: Thank you! :pray:

1 Like