Basically, what I’m trying to make is when you hover over the button, it changes to red and stays like that until you hover on another button. Now the changing it to red part works, but none of them change back when I hover over something else. Here’s my code, and a video to show the issue I’m having.
local buttons = {
script.Parent.MenuBack.Buttons.Continue,
script.Parent.MenuBack.Buttons.New,
script.Parent.MenuBack.Buttons.Quit,
script.Parent.MenuBack.Buttons.Settings
}
local regularColor = Color3.new(1,1,1)
local hoverTextColor = Color3.new(0.701961, 0, 0)
local currentSelectedButton = buttons[1].Parent.buttonSelected
buttons[1].MouseEnter:Connect(function()
buttons[1].TextColor3 = hoverTextColor
buttons[1].TextLabel.TextColor3 = hoverTextColor
if currentSelectedButton.Value == 2 then
currentSelectedButton.Value = 1
buttons[2].TextColor3 = regularColor
buttons[2].TextLabel.TextColor3 = regularColor
elseif currentSelectedButton.Value == 3 then
currentSelectedButton.Value = 1
buttons[3].TextColor3 = regularColor
buttons[3].TextLabel.TextColor3 = regularColor
elseif currentSelectedButton.Value == 4 then
currentSelectedButton.Value = 1
buttons[4].TextColor3 = regularColor
buttons[4].TextLabel.TextColor3 = regularColor
end
end)
buttons[2].MouseEnter:Connect(function()
buttons[2].TextColor3 = hoverTextColor
buttons[2].TextLabel.TextColor3 = hoverTextColor
if currentSelectedButton.Value == 1 then
currentSelectedButton.Value = 2
buttons[1].TextColor3 = regularColor
buttons[1].TextLabel.TextColor3 = regularColor
elseif currentSelectedButton.Value == 3 then
currentSelectedButton.Value = 2
buttons[3].TextColor3 = regularColor
buttons[3].TextLabel.TextColor3 = regularColor
elseif currentSelectedButton.Value == 4 then
currentSelectedButton.Value = 2
buttons[4].TextColor3 = regularColor
buttons[4].TextLabel.TextColor3 = regularColor
end
end)
buttons[3].MouseEnter:Connect(function()
buttons[3].TextColor3 = hoverTextColor
buttons[3].TextLabel.TextColor3 = hoverTextColor
if currentSelectedButton.Value == 1 then
currentSelectedButton.Value = 3
buttons[1].TextColor3 = regularColor
buttons[1].TextLabel.TextColor3 = regularColor
elseif currentSelectedButton.Value == 2 then
currentSelectedButton.Value = 3
buttons[2].TextColor3 = regularColor
buttons[2].TextLabel.TextColor3 = regularColor
elseif currentSelectedButton.Value == 4 then
currentSelectedButton.Value = 3
buttons[4].TextColor3 = regularColor
buttons[4].TextLabel.TextColor3 = regularColor
end
end)
buttons[4].MouseEnter:Connect(function()
buttons[4].TextColor3 = hoverTextColor
buttons[4].TextLabel.TextColor3 = hoverTextColor
if currentSelectedButton.Value == 1 then
currentSelectedButton.Value = 4
buttons[1].TextColor3 = regularColor
buttons[1].TextLabel.TextColor3 = regularColor
elseif currentSelectedButton.Value == 2 then
currentSelectedButton.Value = 4
buttons[2].TextColor3 = regularColor
buttons[2].TextLabel.TextColor3 = regularColor
elseif currentSelectedButton.Value == 3 then
currentSelectedButton.Value = 4
buttons[3].TextColor3 = regularColor
buttons[3].TextLabel.TextColor3 = regularColor
end
end)
And sorry for making you watch that whole scene, skip about like 20 or so seconds in.
Also if you have any recommendations on how to make this code much shorter please feel free to let you know. I’m probably doing this the worst way possible.