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

whats the key:byte code for mouse button 1?

NOTE : this is not a gui button this is for something else

I just need to kow the key:byte id/code for left mouse button / mouse button 1

heres my script

player = game.Players.LocalPlayer
mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
if key:byte() == 1 then 
print'u wot m8'
end
end)

2 answers

✓ Accepted answer
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:connect(function()
	--stuff
end)

1 comment

1

I didn't thumbs it down

ForeverDev didn't mention it, but key presses on a keyboard have KeyCodes associated with them because of letter encodings, not because of a generic input ID. Mouse events use their own, well, events.

By the way, I suggest reasearching and using the UserInputService instead of GetMouse for most things. You don't get the problem of KeyDown reserving keys, and you get more flexibility in the form of the Function buttons and the separation of '2' and 'LeftShift'

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