Hi, there. I’m trying to make it so that all the buttons in the “Buttons” frame work from a single script.
I’m trying to make it so that when you hover on each one, a hover frame inside it changes it’s transparency to 0.9 on mouse enter and 1 on mouse leave.
So, I’m having trouble running this from a single script. I can’t do for i,v, since that will activate every single button’s hover function. I’m running the hover function from a module.
Instances Location - https://gyazo.com/0b7e373fda75081a0005f395228eb7b4
Main Script Code
local Screen_UI = script.Parent.Parent
local Client__ = Screen_UI.Client
local Tween_Service__ = game:GetService("TweenService")
local __Buttons_ = Client__:WaitForChild("Buttons")
local Buttons = {"Handto", "More", "Shop"}
function LayOutModules()
for i = 1, #Buttons do
if __Buttons_.i then
script.Parent.Modules.Hover:Clone().Parent = i
require(i.Hover)
end
end
end
LayOutModules()
Module Code
local module = {}
local Tween__Service = game:GetService("TweenService")
script.Parent.MouseEnter:Connect(function()
if script.Parent:IsA("TextButton") then
Tween__Service:Create(script.Parent:WaitForChild("Hover_Image"), TweenInfo.new(0.3, Enum.EasingStyle.Linear), {BackgroundTransparency = 0.9}):Play()
end
end)
script.Parent.MouseLeave:Connect(function()
if script.Parent:IsA("TextButton") then
Tween__Service:Create(script.Parent:WaitForChild("Hover_Image"), TweenInfo.new(0.3, Enum.EasingStyle.Linear), {BackgroundTransparency = 1}):Play()
end
end)
return module