You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Once I have my GUI Tweened in I wish to have it Tween out.
What is the issue? After the first Tween the second Doesn’t play.
What solutions have you tried so far? Rewriting certain parts of my script. As well as looking on the DevForum to which neither of these things worked.
I don’t usually use Tweens so I really don’t know what I’m doing. However my code isn’t getting any errors on use, so I don’t know why my second Tween isn’t playing.
My code:
local TS = game:GetService('TweenService')
local flashMenu = script.Parent.Parent
local flashUI = script.Parent
local triggerButton = game.Workspace["DemonCore(BigChonker)"].DemonCore.Model.TriggerButton
local coolDown = triggerButton.Parent.Cooldown
repeat wait() until game:IsLoaded(true)
flashMenu.Enabled = false
triggerButton.MouseClick:Connect(function()
flashMenu.Enabled = true
local Tween1Info = TweenInfo.new(
0.01,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In,
false,
nil
)
local Tween1 = TS:Create(flashUI, Tween1Info,{Transparency = 0})
wait(0.01)
Tween1:Play()
Tween1.Completed:Wait(1)
local Tween2Info = TweenInfo.new(
2,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
false,
nil
)
local Tween2 = TS:Create(flashUI, Tween2Info, {Transparency = 1})
wait(0.01)
Tween2:Play()
if Tween2.Completed then
flashMenu.Enabled = false
coolDown.Value = true
wait(90)
coolDown.Value = false
end
end)
(Note: The script is located inside the object I’m Tweening while the activation item is in a folder in the Workspace.)
For a basic run-down on what the script does, if it’s a little confusing. When the trigger key gets pressed it enables the ScreenGUI and then plays the flash Tween. Then it waits till that Tween is over and then plays the SecondTween to Tween out.
Make sure your UI is in PlayerGui that way clients can modify it:
local gui = script.Parent.Parent
local player = game.Players.LocalPlayer
gui.Parent = player.PlayerGui
Also if you want your UI to tween out
You can use this:
Tween1:Cancel() -- This stops the previous Tween
task.wait(0.1)
TweenService:Create(flashUI, TweenInfo.new(2), {Transparency = 1}):Play() -- Reverts ui to what it was previously.