What do you want to achieve? Keep it simple and clear!
Alright, so there are one textbutton responsible for open/close the Shop. When you click on “Open Shop” the shop will bounce to the end position. Then the shop will change the text to “Close” and the color to red. When you click on “Close” it should bounce back to the start position.
I am sorry for not being as specific as the things I want to achieve.
What is the issue? Include screenshots / videos if possible!
There is no error in the output and when I click on the button (Open Shop) it bounce to the end position. The thing is that it doesn’t bounce back to the start position after clicking on the same button.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried doing sum research on google and developer forum but I could not find a way to fix this.
local OpennCloseUI = script.Parent.OpenNCloseUI
local Shop = script.Parent.Shop
local player = game.Players.LocalPlayer
OpennCloseUI.MouseButton1Click:Connect(function(player)
if Shop.Visible == false then
Shop.Visible = true
Shop:TweenPosition(
UDim2.new(0.385, 0,0.181, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Elastic,
1,
false
)
OpennCloseUI.BackgroundColor3 = Color3.new(1, 0, 0)
OpennCloseUI.Text = "Close"
else
OpennCloseUI.BackgroundColor3 = Color3.new(0, 255, 0)
Shop:TweenPosition(
UDim2.new(0.403, 0,-0.608, 0),
Enum.EasingDirection.InOut,
Enum.EasingStyle.Elastic,
1,
false
)
OpennCloseUI.Text = "Open Shop"
Shop.Visible = false
end
end)
ths is what happen when I put the wait() the Shop and the text of the button delay when changing the text back to |Open Shop| and making the Shop visible.
Hi, the issue you have (may have been solved already), is that you are disabling the visibility of the frame as soon as the tween runs, so the tween is running but the frame is just not visible for you to see. Very simple fix is that you could add a :wait() then in the brackets just put the length of the tween, so it knows how long to wait. But you will need to set a time value into the tween as you haven’t done so.
Example Script
OpennCloseUI.MouseButton1Click:Connect(function(player)
if Shop.Visible == false then
Shop.Visible = true
Shop:TweenPosition(
1, -- Length(at the moment it is set to 1)
UDim2.new(0.385, 0,0.181, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Elastic,
1,
false
)
OpennCloseUI.BackgroundColor3 = Color3.new(1, 0, 0)
OpennCloseUI.Text = "Close"
else
OpennCloseUI.BackgroundColor3 = Color3.new(0, 255, 0)
Shop:TweenPosition(
1, -- Length(at the moment it is set to 1)
UDim2.new(0.403, 0,-0.608, 0),
Enum.EasingDirection.InOut,
Enum.EasingStyle.Elastic,
1,
false
)
OpennCloseUI.Text = "Open Shop"
wait(1)
Shop.Visible = false
end
end)