Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Mouse a nil value? (answered)

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 comments

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.

1

I didn't even notice the connect error, thank you

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.