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

Help with KeyUp event?

For some reason when I press the Q key it does line 7 but not line 5,why and how do I fix it?

game.Players.PlayerAdded:connect(function(Player)
		PlayerMouse = Player:GetMouse()
	PlayerMouse.KeyDown:connect(function(Key)
		if Key == q then
			print(Key,"has been pressed")
		else
			print(Key,"is the wrong key")
		end
	end)
end)

1 answer

✓ Accepted answer

You forgot to put the 'q' into quotes (This is a quote: ");

game.Players.PlayerAdded:connect(function(Player)
repeat wait(0)until Player:GetMouse() --I like to use this to wait until the script gets the Player's Mouse before going on
PlayerMouse = Player:GetMouse()
PlayerMouse.KeyDown:connect(function(Key)
if Key == "q" then --Here we go, you Silly Billy :)
print(Key,"has been pressed")
else
print(Key,"is the wrong key")
end
end)
end)

Hope this helped!

1 comment

0

My bad :3

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