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

whats the key:byte code for mouse button 1?

Asked by
Prioxis 673 Moderation Voter
10 years ago

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

Log in to vote
1
Answered by 10 years ago
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:connect(function()
    --stuff
end)
1
I didn't thumbs it down Prioxis 673 — 10y
Ad
Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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'

Answer this question