Hello Devs,
I was making animations for my game’s UI, but I’ve run into a “problem”, not necessarily a script breaking problem, but still annoying.
When I double click or click fast on the button to open the menu and then close again quickly, I get what I want, everything is good and smooth. But, if i do the same and try to close and reopen the menu, it just doesn’t.
Here’s a video showing my problem:
(I hope you understand whats happening)
And here’s my script:
local button = script.Parent
local frame = script.Parent.Parent.Parent.test
local ts = game:GetService("TweenService")
local function createTween(object, properties, duration, easingStyle, easingDirection, delaY)
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle[easingStyle], Enum.EasingDirection[easingDirection], 0, false, delaY)
local tween = ts:Create(object, tweenInfo, properties)
return tween
end
button.MouseButton1Click:Connect(function()
if frame.Visible == false then
local uiTweenOpen = createTween(frame, {Position = UDim2.new(0.396, 0,0.315, 0), BackgroundTransparency = 0}, 0.25, "Quad", "Out", 0)
frame.Visible = true
uiTweenOpen:Play()
else
local uiTweenClose = createTween(frame, {Position = UDim2.new(0.396, 0,0.351, 0), BackgroundTransparency = 1}, 0.25, "Quad", "Out", 0)
uiTweenClose:Play()
task.wait(.25)
frame.Visible = false
end
end)
I think the problem is the “task.wait(.25)” but I’m not sure
I’d be happy if someone could help me