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

How do you go about fixing a local mouse which is (nil)?

Asked by 5 years ago
Edited 5 years ago

attempt to index local 'mouse' (a nil value)

Error on line 2422

Came up into my output when I ran a script. These are whats used.

1local Player = game.Players.RandomPlayerNameHere
2local mouse = Player:GetMouse()

Then skip to line 2422 (where the error is):

01mouse.KeyDown:connect(function(key) -- Line 2422
02    if key == "z" and attack == false then
03 attack1()
04    end
05end)
06 
07 
08 
09mouse.KeyDown:connect(function(key)
10    if key == "x" and attack == false then
11         attack2()
12    end
13    end)
14 
15 
View all 27 lines...

And I have 0 clue as to what I've done wrong. If you need to see any other parts of the script I'd be happy to oblige. Any ideas as to how to fix this is appreciated.

0
GetMouse is only available locally. pidgey 548 — 5y
0
You're using a server script, or you're generally not using the LocalPlayer. Basically, use a LocalScript. User#6546 35 — 5y
0
Look at contextactionservice and then fire remote events when a player clicks one of the buttons. MachoPiggies 526 — 5y
0
jeez line 2422 thats a big script AltNature 169 — 5y

Answer this question