Hello! When I press the “BackButton” the tween doesn’t play.
Snippet
BackButton.MouseButton1Down:Connect(function()
if Settings["Gui Position Tweens"] then
for i, Buttons in pairs(MainFrame:GetChildren()) do
if Buttons:IsA("TextButton") or Buttons:IsA("ImageButton") then
local ButtonPosX = Buttons.Position.X
local ButtonPosY = Buttons.Position.Y
local Animate = Num
MainFrame.Visible = true
local tween = ts:Create(Buttons, info, {Position = UDim2.new(ButtonPosX.Scale, ButtonPosX.Offset + Animate, ButtonPosY.Scale, ButtonPosY.Offset + Animate)}) -- if you changed the tween above with - or +, then do the opposite here, so example - for tween above then change it to + to this tween
tween:Play()
tween.Completed:Connect(function()
UILISTLAYOUT.Parent = MainFrame
end)
print("Back")
end
end
else
MainFrame.Visible = true
print(MainFrame.Visible)
end
end)
You didn’t say if “Back” getting printed in the console. If it isn’t, well then something has to be wrong with your if or for statements. If it is, I’d guess that something is wrong with your Udim2, but I never use offsets, so I wouldn’t know what it is, unless maybe animate and num are both equal to 0. I would also recommend tweening position to “goal” and setting goal equal to your Udim2, as in my personal experience having more readable code helps me find out what’s wrong much faster.
Back works because the mainframe turns visible which can only be turned on when the button is clicked. Num is = 400. If wanted, I could post the full code
Figured about why. Turns out that I was adding it to the Y-value so it was playing but not right.
local ts = game:GetService("TweenService")
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut) -- Changeble (Time, EasingStyle, EasingDirection)
local Gui = script.Parent
local MainFrame = Gui.MainFrame
local UILISTLAYOUT = MainFrame.UIListLayout
local PlayButton = MainFrame.PlayButton
local SettingButton = MainFrame.SettingButton
local BackButton = Gui.BackButton
local Num = 400 -- Don't change!
local Settings = {
["Gui Position Tweens"] = true; -- Animate gui once it's clicked, set true if yes, set false if no
["Settings Button"] = true -- Allows the settings button to be visible, set true if yes, set false if no
}
if Settings["Settings Button"] then
SettingButton.Visible = true
else
SettingButton.Visible = false
end
PlayButton.MouseButton1Down:Connect(function()
if Settings["Gui Position Tweens"] then
for i, Buttons in pairs(MainFrame:GetChildren()) do
if Buttons:IsA("TextButton") or Buttons:IsA("ImageButton") then
local ButtonPosX = Buttons.Position.X
local ButtonPosY = Buttons.Position.Y
UILISTLAYOUT.Parent = Gui.Parent
local Animate = Num --Don't change
local tween = ts:Create(Buttons, info, {Position = UDim2.new(Buttons.Position.X.Scale, ButtonPosX.Offset - Animate, Buttons.Position.Y.Scale, ButtonPosY.Offset)}) -- Replace - with + if you want the button to go right or - to go left
tween:Play()
print("CLICKID")
tween.Completed:Connect(function()
MainFrame.Visible = false
end)
end
end
else
MainFrame.Visible = false
end
end)
BackButton.MouseButton1Down:Connect(function()
if Settings["Gui Position Tweens"] then
for i, Buttons in pairs(MainFrame:GetChildren()) do
if Buttons:IsA("TextButton") or Buttons:IsA("ImageButton") then
local ButtonPosX = Buttons.Position.X
local ButtonPosY = Buttons.Position.Y
local Animate = Num
MainFrame.Visible = true
local tween = ts:Create(Buttons, info, {Position = UDim2.new(ButtonPosX.Scale, ButtonPosX.Offset + Animate, ButtonPosY.Scale, ButtonPosY.Offset)}) -- if you changed the tween above with - or +, then do the opposite here, so example - for tween above then change it to + to this tween
tween:Play()
tween.Completed:Connect(function()
UILISTLAYOUT.Parent = MainFrame
end)
print("Back")
end
end
else
MainFrame.Visible = true
print(MainFrame.Visible)
end
end)