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.

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

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

mouse.KeyDown:connect(function(key) -- Line 2422 
    if key == "z" and attack == false then
 attack1()
    end
end)



mouse.KeyDown:connect(function(key)
    if key == "x" and attack == false then
         attack2()
    end
    end)



mouse.KeyDown:connect(function(key)
    if key == "v" then

if autofind == false then
autofind = true
else 
autofind = false        
end

end
end)

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