local ContextActionService = game:GetService("ContextActionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Usages = ReplicatedStorage.Usage
local Keybinds = require(Usages.Client.Keybinds)
local function MainFunction(actionName, InputState, InputObject)
if actionName == "Portafab" and InputState == Keybinds[actionName].EnumType then
require(Usages.Tools[tostring(actionName)])("Start", InputObject)
elseif InputState == Keybinds[actionName].EnumType then
require(Usages.Tools[tostring(actionName)])("Start", InputObject)
end
end
ContextActionService.LocalToolEquipped:Connect(function(a)
ContextActionService:BindAction(a.Name, MainFunction, false, unpack(Keybinds[tostring(a)]))
end)
ContextActionService.LocalToolUnequipped:Connect(function(a)
ContextActionService:UnbindAction(a.Name)
end)
-- // Keybind
return {
Portafab = {
Enum.KeyCode.Z,
Enum.KeyCode.X,
Enum.KeyCode.C,
Enum.UserInputType.MouseButton1,
EnumType = Enum.UserInputState.Begin
},
["Satchel Charge"] = {
Enum.UserInputType.MouseButton1,
Enum.KeyCode.E,
EnumType = Enum.UserInputState.Begin
},
["Cruise Missile"] = {
Enum.UserInputType.MouseButton1,
EnumType = Enum.UserInputState.Begin
}
}
-- // First Tool
return function (Action, ActionKey)
local function Key(Keys)
if Keys.KeyCode then
return Keys.KeyCode
elseif Keys.UserInputType then
return Keys.UserInputType
end
end
if Action == "Start" then
print(Key(ActionKey))
else
return
end
end
I’m trying to separate keybinds to a specific tools. but the problem is that it only detects KeyCodes not userInputType
everything works it prints out Enum.KeyCode.Z, Enum.KeyCode.X but other than when I try to click a MouseButton1 I get Enum.KeyCode.Unknown
Video: https://gyazo.com/cfe5ac35542ae6e4b9161bbff3dafc36
I’m trying to get:
Enum.KeyCode.Z
Enum.KeyCode.X
Enum.KeyCode.C
AND
Enum.UserInputType.MouseButton1
But the code I have in section 3 block it doesn’t detect UserInputType and I have no idea to do it. I have tried using the Enum properties “EnumType” but it doesn’t work.