I’m new to Tweening GUIs, how would I detect when a tween is finished for this code?
local circle = script.Parent
local openbutton = script.Parent.Parent.Frame.TweenButton
openbutton.MouseButton1Up:Connect(function()
--open it/tween it
circle:TweenSizeAndPosition(
UDim2.new(0,587,0,587),-- end size
UDim2.new(0.275, 0,0, 0), -- end pos
"Out", -- easing direction
"Quad", -- easing style
1.5, --time in seconds
false --override?
)
end)
I just don’t know how to check for when a tween is completed.
Edit: I didn’t actually need it, but thanks everyone. If you are having this problem, just check the replies.
I’m not sure if that’ll work since they’re used for Tweens created by TweenService, these are tweens made using the Built in tweening functions for GuiObjects
local circle = script.Parent
local openbutton = script.Parent.Parent.Frame.TweenButton
openbutton.MouseButton1Up:Connect(function()
local function OnTweenFinish(state)
if state == Enum.TweenStatus.Completed then
--we know that the tween has been competed
end
end
--open it/tween it
circle:TweenSizeAndPosition(
UDim2.new(0,587,0,587),-- end size
UDim2.new(0.275, 0,0, 0), -- end pos
"Out", -- easing direction
"Quad", -- easing style
1.5, --time in seconds
false --override?
OnTweenFinish -- you can add functions to the tween here
)
end)
Wait doesn’t the GuiObject tweening methods return you a boolean if the tween was completed or not for the parameter of the callback function? If so, shouldn’t it be
local function OnTweenFinish(completed)
if completed then
--we know that the tween has been competed
end
end
In roblox examples in the teaching website they tell you that you should always check the state using Enum.TweenStatus I don’t think It returns a boolean I might be wrong. I think using the boolean technique if (there is one) is bad practice
local function callbackName()
-- tells you if the tween is completed
end
openbutton.MouseButton1Up:Connect(function()
--open it/tween it
circle:TweenSizeAndPosition(
UDim2.new(0,587,0,587),-- end size
UDim2.new(0.275, 0,0, 0), -- end pos
"Out", -- easing direction
"Quad", -- easing style
1.5, --time in seconds
false --override?
callbackName -- the call back
)
end)