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

Mouse a nil value? (answered)

Asked by 4 years ago
Edited 4 years ago
local Mouse = game.Players:WaitForChild("Jack_Hase"):GetMouse()
    Mouse.Button1Down:connect(function(NEWKEY)
        MouseDown(NEWKEY)
    end)
    Mouse.Button1Up:connect(function(NEWKEY)
        MouseUp(NEWKEY)
    end)
    Mouse.KeyDown:connect(function(NEWKEY)
        KeyDown(NEWKEY)
    end)
    Mouse.KeyUp:connect(function(NEWKEY)
        KeyUp(NEWKEY)
    end)

I was fixing an old script (FE change I think) , but I kept getting an error at Mouse.Button1Down:connect(function(NEWKEY), saying the variable is nil even though right above it i define mouse, I've taken this part out of the script, same error nothing different, any solutions? (also to all those people who spam replies what the error message was it is Workspace.Script:2: attempt to index local 'Mouse' (a nil value) ok now dont spam my replies thank you)

2
You can't use :GetMouse() in ServerScripts, only in LocalScripts. And :connect is deprecated use :Connect and Mouse.KeyDown/Up is deprecated, use the UserInputService. yHasteeD 1819 — 4y
1
I didn't even notice the connect error, thank you Jack_Hase 85 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Answered by yHasteeD. "You can't use :GetMouse() in ServerScripts, only in LocalScripts. And :connect is deprecated use :Connect and Mouse.KeyDown/Up is deprecated, use the UserInputService." Thank you! I've solved this problem in my script now

Ad

Answer this question