Currently have a Billboard UI inside of an object that tweens the UI to fill up the bar. Tweening works fine but I’m having trouble figuring out the Completed part of the tween. When it completes and fills up the bar it’s supposed to print “completed” in the output, which it does when its 100% but if my mouse leaves and re-enters the bar it prints still.
local board = script.Parent.BillboardGui
local click = script.Parent.ClickDetector
local Fill = board.Frame.FIll
local text = script.Parent.BillboardGui.Frame.TextLabel
local TweenService = game:GetService("TweenService")
local START_SIZE = Fill.Position
local GOAL_SIZE = UDim2.new(0.5,0,0.5,0)
local TIME = 10
local TIMEEND = 1
local info = TweenInfo.new(
TIME,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local infotwo = TweenInfo.new(
TIMEEND,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local mouseEnterTween = TweenService:Create(Fill, info, {Position = GOAL_SIZE})
local mouseLeaverTween = TweenService:Create(Fill, infotwo, {Position = START_SIZE})
click.MouseHoverEnter:Connect(function()
if not script.Parent:FindFirstChild("SelectionBox") then
local s = Instance.new("SelectionBox")
s.Adornee = script.Parent
s.Parent = script.Parent
s.Color3 = Color3.new(1, 0.32549, 0.337255)
board.Enabled = true
mouseEnterTween:Play()
mouseEnterTween.Completed:Wait()
print ("completed")
end
end)
click.MouseHoverLeave:Connect(function()
if script.Parent:FindFirstChild("SelectionBox") then
script.Parent.SelectionBox:Destroy()
mouseLeaverTween:Play()
end
end)
Does anyone know how to fix this?