What do I want to achieve?
I want to animate my Gui. First one shall go up when settings button gets clicked and settingsGui’s two parts shall merge together.
What is the issue?
First Gui has a tween and second has lerping but none of them are working. It wasn’t like this before. Also it isn’t disappearing when other one comes on. help me dear forum members - YouTube
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I revised Lerping, changed the script’s waits, looked at the UDim2:Lerp post on Developer Forum and asked other people.
Script:
local button = script.Parent.Parent:FindFirstChild("DefaultSettings")
local settingIcon = script.Parent.Parent.Parent:FindFirstChild("Settings")
local empty = "rbxassetid://4896991066"
local ticked = "rbxassetid://4896991006"
local RepStorage = game:GetService("ReplicatedStorage")
local remote = RepStorage.RemoteEvents.ValueChanger
local tweenService = game:GetService("TweenService")
local frame = script.Parent.Parent.Parent.Parent:FindFirstChild("MainFrame")
local newPos = UDim2.new(-0.5,0,-0.5,0)
frame.Position = UDim2.new(0.029,0,0.039,0)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 1, false)
local tween = tweenService:Create(frame, tweenInfo, {Position = newPos})
local settingsGui = RepStorage.Guis.SettingsMenu
local Menus = settingsGui.Menus
local Settings = settingsGui.Settings
local MenuGoal = UDim2.new(0.153,0,0.933,0)
local SettingGoal = UDim2.new(0.791,0,0.933,0)
local SettingBegin = UDim2.new(0.791,0,0.933,0) --Reason I'm setting this is I don't want to change its' position every time I edit the Gui so it'll change when it's generated.
local MenuBegin = UDim2.new(0.153,0,0.933,0)
local clicked = false
local db = false
button.MouseButton1Click:Connect(function()
db = true
if clicked == false then
clicked = true
else
clicked = false
end
if clicked then
if db then
settingIcon.Visible = true
button.Image = empty
db = false
end
else
if db then
settingIcon.Visible = false
button.Image = ticked
db = false
end
end
end)
settingIcon.MouseButton1Click:Connect(function()
remote:FireServer("UseDefaultSettings", false)
local copiedGui = settingsGui:Clone()
copiedGui.Parent = game.Players.LocalPlayer.PlayerGui
Menus.Position = MenuBegin
Settings.Position = SettingBegin
wait(1)
frame.Visible = false
for i = 0.1, 00.1 do
Menus.Position:Lerp(MenuGoal, i)
wait()
end
for i = 0.1, 00.1 do
Settings.Position:Lerp(SettingGoal, i)
wait()
end
end)
I’ve already used one tween and not sure if three tweens will work in a sync or affect overall performance. I don’t need animations or something so I prefered lerps.
You tested using the second code I referenced, correct (Not the quote)?
I tried this & it worked perfectly for me.
Menus = script.Parent
local MenuGoal = UDim2.new(0.153 ,0 ,0.933 ,0)
for i = 0,1,.1 do
Menus.Position = Menus.Position:Lerp(UDim2.new(MenuGoal), i)
wait()
end
Also, the tweens (on different frames) should work in sync as long as you’re not trying to change the same property on the same frame. (Personally I would prefer tweening in this case)
I fixed it with Tweens but it was still really hard. My issues:
I changed props when it’s in Replicated Storage so it didn’t show up.
My Gui variables were wrong.
I accidently put size in position part.
And here’s the new script:
local button = script.Parent.Parent:FindFirstChild("DefaultSettings")
local settingIcon = script.Parent.Parent.Parent:FindFirstChild("Settings")
local empty = "rbxassetid://4896991066"
local ticked = "rbxassetid://4896991006"
local RepStorage = game:GetService("ReplicatedStorage")
local remote = RepStorage.RemoteEvents.ValueChanger
local tweenService = game:GetService("TweenService")
local frame = script.Parent.Parent.Parent.Parent:FindFirstChild("MainFrame")
local newPos = UDim2.new(0.029, 0,-0.922, 0)
frame.Position = UDim2.new(0.029,0,0.039,0)
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0, false)
local tween = tweenService:Create(frame, tweenInfo, {Position = newPos})
local tweenInfoMenuNSettings = TweenInfo.new(1,Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local settingsGui = RepStorage.Guis.SettingsMenu
local MenuGoal = UDim2.new(0.022, 0,0.033, 0)
local SettingGoal = UDim2.new(0.174, 0,0.033, 0)
local SettingBegin = UDim2.new(0.999, 0,0.033, 0)
local MenuBegin = UDim2.new(-0.153, 0,0.033, 0)
local clicked = false
local db = false
button.MouseButton1Click:Connect(function()
db = true
if clicked == false then
clicked = true
else
clicked = false
end
if clicked then
if db then
settingIcon.Visible = true
button.Image = empty
db = false
end
else
if db then
settingIcon.Visible = false
button.Image = ticked
db = false
end
end
end)
settingIcon.MouseButton1Click:Connect(function()
remote:FireServer("UseDefaultSettings", false)
tween:Play()
local copiedGui = settingsGui:Clone()
copiedGui.Parent = game.Players.LocalPlayer.PlayerGui
local Menus = copiedGui.Menus
local Settings = copiedGui.Settings
Menus.Position = MenuBegin
Settings.Position = SettingBegin
local tweenSetting = tweenService:Create(Settings,tweenInfoMenuNSettings, {Position = SettingGoal})
local tweenMenu = tweenService:Create(Menus,tweenInfoMenuNSettings, {Position = MenuGoal})
wait(0.9)
frame.Visible = false
wait()
tweenSetting:Play()
tweenMenu:Play()
Menus.Visible = true
Settings.Visible = true
end)