Basically, I am using the Fe Melee Kit and noticed it did not support controller support, so I decided to add it myself with some tinkering and manage to get it working. The issue is, on a certain line of code, it changes the key icon to either that of a keyboard or the controller icon. Both keybinds work with no issue, the issue is getting the right icon to appear based on if a player has a gamepad connected or if they’re using keyboard. My issue with my code is if I remove a certain line of code, the keyboard icons will appear but If I leave the code in, the controller icons only appear. I tried to use a boolean using userinputservice but that did not work at all.
local ControllerIcons = {
["DPadUp"] = {"rbxassetid://9707172808", "[UP]"},
["DPadDown"] = {"rbxassetid://9707173263", "[DOWN]"},
["DPadLeft"] = {"rbxassetid://9707173914", "[LEFT]"},
["DPadRight"] = {"rbxassetid://9707174722", "[RIGHT]"},
["ButtonA"] = {"rbxassetid://9707175322", "[A]"},
["ButtonB"] = {"rbxassetid://9707175872", "[B]"},
["ButtonX"] = {"rbxassetid://9707176695", "[X]"},
["ButtonY"] = {"rbxassetid://9707177273", "[Y]"},
["Thumbstick1"] = {"rbxassetid://9707179133", "[LEFT STICK]"},
["ButtonL3"] = {"rbxassetid://9707179856", "[LEFT STICK]"},
["Thumbstick2"] = {"rbxassetid://9707180722", "[RIGHT STICK]"},
["ButtonR3"] = {"rbxassetid://9707181861", "[RIGHT STICK]"},
["ButtonSelect"] = {"rbxassetid://9707184078", "[SELECT]"},
["ButtonStart"] = {"rbxassetid://9707184880", "[START]"},
["ButtonL1"] = {"rbxassetid://9707186809", "[LB1]"},
["ButtonR1"] = {"rbxassetid://9707187588", "[RB1]"},
["ButtonL2"] = {"rbxassetid://9707189488", "[LB2]"},
["ButtonR2"] = {"rbxassetid://9707189941", "[RB2]"}
}
local Abilities = {}
local ISAbilities = GetAbilities:InvokeServer()
local gamepadenable = UIS.GamepadEnabled
ReleaseInput.OnClientEvent:Connect(function(AN)
for _,AB in pairs(Abilities) do
if AB[1] == AN then
HandleAbilityDelay(AB)
end
end
end)
for i, Ability in pairs(ISAbilities) do
if #Ability ~= 0 then
local aFrame = AbilityUI.aFrameEXAMPLE:Clone()
aFrame.Parent = AbilityUI
aFrame.Position = UDim2.new(1, -220, 1, -120 - (110*(i-1)))
aFrame.AbilityNameFrame.AbilityName.Text = Ability[1]
aFrame.AbilityDescription.Text = Ability[2]
aFrame.AbilityKey.Text = string.gsub(tostring(Ability[4]) , "Enum.KeyCode.", "")
aFrame.Visible = true
table.insert(Abilities,{Ability[1],Ability[3],Ability[4],Ability[2],aFrame})
if print("HELLO WORLD") then
for ii, vv in pairs(Ability[4]) do
if typeof(vv) == "table" then
if gamepadenable == false then
local inputIcon = AbilityUI.InputTemplates[UIS.GamepadEnabled and "Controller" or "Keyboard"].KeyIcon:Clone()
if UIS.GamepadEnabled then
inputIcon.Icon.Image = ControllerIcons[vv.Controller]
else
inputIcon.TextLabel.Text = vv.Keyboard
end
inputIcon.Name = ii
inputIcon.LayoutOrder = ii
inputIcon.Visible = true
inputIcon.Parent = aFrame.AbilityKey
else
local inputIcon = AbilityUI.InputTemplates[UIS.GamepadEnabled and "Controller" or "Keyboard"]:FindFirstChild(vv)
if inputIcon then
local clone = inputIcon:Clone()
clone.Name = ii
clone.LayoutOrder = ii
clone.Visible = true
clone.Parent = aFrame.AbilityKey
end
end
end
end
elseif gamepadenable == true then
local inputIcon = AbilityUI.InputTemplates[UIS.GamepadEnabled and "Controller"].KeyIcon:Clone()
if UIS.GamepadEnabled then
inputIcon.Icon.Image = ControllerIcons[string.gsub(tostring(Ability[5]) , "Enum.KeyCode.", "")][1]
else
inputIcon.TextLabel.Text = string.gsub(tostring(Ability[1]) , "Enum.KeyCode.", "")
end
inputIcon.Visible = true
inputIcon.Parent = aFrame.AbilityKey
end
end
end