Mouse.Key
local Button = { Key00 = "b" }; game:GetService("Players").LocalPlayer:GetMouse().KeyDown:Connect(function(Key) if (Key == "a") then print ("Hello World!"); elseif (Key == Button["Key00"]) then print ("Hello World!") end end)
UserInputService
--Enum to String (easy to do) local String = tostring(EnumValue.Value); --'EnumValue' is just an example, let's just say 'EnumValue' contains an EnumItem data value --Easy to convert with the help of 'tostring()' ---------------------------------------------------------------- --String to Enum (Painful to do, especially when doing it with multiple datas) local Enum_String = "Enum.KeyCode.B"; local EnumToString = function(Value) for _, Data in next, Enum.KeyCode:GetEnumItems() do if (tostring(Data) == Enum_String) then return Data; end end end local Key_B = EnumToString(Enum_String); ---------------------------------------------------------------- --Dictionary local Button = { Key00 = "d" }; ---------------------------------------------------------------- game:GetService("UserInputService").InputBegan:Connect(function(Key, Event) if (Key.KeyCode == Enum.KeyCode.A) then elseif (Key.KeyCode == Key_B) then elseif (Key.KeyCode == "c") then --Will throw an error elseif (Key.KeyCode == Button["Key00"]) then --Will throw an error elseif (Key.KeyCode == Enum.KeyCode."") then --Will throw an error end end)
Mouse.Key is easy to access, but lacks features that UserInputService have and considered deprecated, hence the majority recommends me to use UserInputService instead
I'm still using Mouse.Key because of how quick and easy to make one and easy to re-bind, I wouldn't mind it being deprecated or lacking some features, though I'm kind of worried when it comes with performance
My issue is that I'm uncertain whether Mouse.Key or UIS have their advantage performance-wise, or maybe the performance were negligible for both?
I've already stated earlier of why I'm still sticking to Mouse.Key, but another reason why I'm avoiding UIS is because of Enum usage, which has its own Data Type, and has to take extra steps to convert it (Enum>String & String>Enum), basically a pain in the ass to manage due to it being incompatible to any kinds of Data Types
And here I am, still uncertain whether migrating to UserInputService usage is worth the pain, hence I come here to ask
Any answers are appreciated, thanks in advance!