Hi, I have 4 buttons in my gui, and I made them change colour when someone places their mouse over the button. The script works perfectly, but I was wondering, is there a more efficient/better way of doing this? because it seems so repetitive.
local ADF = script.Parent:WaitForChild('ADF')
local AFW = script.Parent:WaitForChild('AFW')
local AGK = script.Parent:WaitForChild('AGK')
local AMF = script.Parent:WaitForChild('AMF')
ADF.MouseEnter:connect(function()
ADF.BackgroundColor3 = Color3.fromRGB(17, 135, 165)
end)
ADF.MouseLeave:connect(function()
ADF.BackgroundColor3 = Color3.fromRGB(22, 174, 214)
end)
AFW.MouseEnter:connect(function()
AFW.BackgroundColor3 = Color3.fromRGB(17, 135, 165)
end)
AFW.MouseLeave:connect(function()
AFW.BackgroundColor3 = Color3.fromRGB(22, 174, 214)
end)
AGK.MouseEnter:connect(function()
AGK.BackgroundColor3 = Color3.fromRGB(17, 135, 165)
end)
AGK.MouseLeave:connect(function()
AGK.BackgroundColor3 = Color3.fromRGB(22, 174, 214)
end)
AMF.MouseEnter:connect(function()
AMF.BackgroundColor3 = Color3.fromRGB(17, 135, 165)
end)
AMF.MouseLeave:connect(function()
AMF.BackgroundColor3 = Color3.fromRGB(22, 174, 214)
end)

2 comments
connect is deprecated it is Connect.
I didn't use connect I just copied and pasted his code but yes good catch