I'm making this loading Gui and the loading bar won't tween properly it stops around (0,0.8, 0,0) and stays there and won't go back to start. Why does it do this and how do I fix it?
Localscript:
---------------------------
function CreateLoadingBar()
local LoadingFrame = script.Parent.TextLabel.LoadingFrame
local Found = LoadingFrame:FindFirstChild("LoadingBar")
if not Found then
local LoadingBar = Instance.new("Frame",LoadingFrame)
LoadingBar.Name = "LoadingBar"
LoadingBar.Size = UDim2.new(0,50,0,35)
LoadingBar.Position = UDim2.new(0,340,0,0)
return LoadingBar
else return Found
end
end
---------------------------
local Finish = UDim2.new(0,0,0,0)
local Start = UDim2.new(0,340,0,0)
Loaded = false
---------------------------
repeat
wait()
LoadingBar = CreateLoadingBar()
print("Loading")
LoadingBar:TweenPosition(Finish,"InOut","Linear",0.5,true)
if LoadingBar.Position == Finish then
print("Loading Bar hit Finish,putting back to start")
LoadingBar:TweenPosition(Start,"Out","Linear",0.5,true)
elseif LoadingBar.Position == Start then
print("Loading Bar hit start,putting back to finish")
LoadingBar:TweenPosition(Finish,"InOut","Linear",0.5,true)
end
until Loaded == true
print("Done")
