Here’s the the code:
local UserInputService = game:GetService("UserInputService")
local KeybindsFolder = game:GetService("ReplicatedStorage"):WaitForChild("Keybinds")
local buttonsArray = {}
local keybindButtonsArray = {}
for i, v in script.Parent.TopMiddleBar:GetChildren() do
if v:IsA("TextButton") then
table.insert(buttonsArray, v)
end
end
for i, v in script.Parent.BottomMiddleBar:GetChildren() do
if v:IsA("TextButton") then
table.insert(buttonsArray, v)
end
end
for i, v in buttonsArray do
v.MouseButton1Click:Connect(function()
if v:GetAttribute("selected") == true then
return
end
for all, buttons in buttonsArray do
buttons.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
buttons:SetAttribute("selected", false)
end
v.BackgroundColor3 = Color3.fromRGB(200, 255, 200)
v:SetAttribute("selected", true)
end)
end
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent == true then
return
end
for i, v in KeybindsFolder:GetChildren() do
if v.Value == input.KeyCode.Name then
local index = nil
for all, buttons in buttonsArray do
if buttons.Name == v.Name then
print(all)
index = all
end
end
local targetButton = buttonsArray[index]
if targetButton:GetAttribute("selected") == true then
return
end
for all, buttons in buttonsArray do
buttons.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
buttons:SetAttribute("selected", false)
end
targetButton.BackgroundColor3 = Color3.fromRGB(200, 255, 200)
targetButton:SetAttribute("selected", true)
end
end
end)
Thanks!