I generally don’t know what to say about what I’m thinking but I don’t know so ill show what I’m trying to do
I want all the other buttons to fade when I click one of the 3 image buttons and a close button to pop up and bring back the buttons when I click it
local pressed = false
local TweenService = game:GetService("TweenService") -- this will get tweenservice
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
script.Parent.MouseEnter:Connect(function()
if pressed == false then
TweenService:Create(script.Parent, tweenInfo, {ImageTransparency = 0.5}):Play()
end
end)
script.Parent.MouseLeave:Connect(function()
if pressed == false then
TweenService:Create(script.Parent, tweenInfo, {ImageTransparency = 0}):Play()
end
end)
script.Parent.MouseButton1Down:connect(function()
pressed = true
TweenService:Create(script.Parent, tweenInfo, {ImageTransparency = 1}):Play()
end)
Well you could just make 2 more lines that create the TweenAnimation copied and pasted, just with the first argument changed to the other instances.
You could also go a more optimized and clean way.
I think you’re putting the question because you don’t know what the first argument exactly does in a TweenService:Create() command. It’s the actual instance (thing) that will get it’s property modified.
I’d rewrite the script this way:
local function TweenTransparency(Inst, NewTransparency)
TweenService:Create(Inst, tweenInfo, {ImageTransparency = NewTransparency})
end)
script.Parent.MouseEnter:Connect(function()
if pressed == false then
TweenTransparency(script.Parent, 0.5)
end
end)
script.Parent.MouseLeave:Connect(function()
if pressed == false then
TweenTransparency(script.Parent, 0)
end
end)
script.Parent.MouseButton1Down:connect(function()
pressed = true
TweenTransparency(script.Parent, 1)
TweenTransparency(script.Parent.Parent.ExtraButton, 1)
TweenTransparency(script.Parent.Parent.SettingsButton, 1)
end)
thanks for helping but also is there a way to link it to other buttons and make it exit? im not the greatest at scripting so im pretty slow at this type on stuff
Well if you mean how you can add this to every button, you just have to change the instance.
For example, if you want to put this into the Settings Button, you have to cover the Chapters Button.
TweenTransparency(script.Parent, 1)
TweenTransparency(script.Parent.Parent.ExtraButton, 1)
TweenTransparency(script.Parent.Parent.ChaptersButton, 1) -- Notice how it changed from SettingsButton (our current parent) to the Chapters Button.