:GetMouse() not working

so im trying to code a gun but player:GetMouse() dosent work!
example:


is there a way to fix this or is it a bug?

3 Likes

You forgot to add “.” betwen Player and WaitForChild at player variable.

You’re waiting for a child named “LocalPlayer” to appear in Players, and LocalPlayer is a property of Players, not a child of it. You have to write game.Players.LocalPlayer instead.

sorry i tried that and it still dosent work

I just looked, and it seems like this is a server script. LocalPlayer on the server is nil, since it’s the player LocalScripts are running for. You need to get the player in some other way.

2 Likes

Since you are getting the mouse of the player, I think GalaxyGourmet is right. Instead, you should write the code in a local script and parent it to starterplayerscripts.

Indeed, you will need LocalScript for it to work.

no you add “:” since its a built in function