Hello, I’m working with a custom loading script and I’ve ran into a problem. The Tween does not work at ALL. I’ve tried 4 different methods and they all haven’t worked. Please tell me whats going on
-- Load --
local Bar1 = LoadUi:WaitForChild('Bar1')
local Bar2 = LoadUi:WaitForChild('Bar2')
local Bar3 = LoadUi:WaitForChild('Bar3')
-- Inos --
local TweenIno = TweenInfo.new(0.3,Enum.EasingStyle.Quint,Enum.EasingDirection.Out)
local MaxGoal = {Size = UDim2.new(0.157,0,0.801,0),Position = UDim2.new(0.732,0,0.519,0)}
local MinGoal = {Size = UDim2.new(0.157,0,0.249,0),Position = UDim2.new(0.244,0,0.806,0)}
-- Tween --
while Bar1.Visible do
TweenSerivce:Create(Bar1,TweenIno,MaxGoal):Play()
task.wait(0.1)
TweenSerivce:Create(Bar1,TweenIno,MinGoal):Play()
task.wait(0.1)
end
---
I think that you need to connect the part in the while loop to an event. as it is now, you check once if the bar is visible when the script first runs, and never check again. so it will not run.
try replacing the loop part with this:
local playing = false
Bar1.Changed:Connect(function()
if playing or not Bar1.Visible then return end
playing = true
while Bar1.Visible do
TweenSerivce:Create(Bar1,TweenIno,MaxGoal):Play()
task.wait(0.1)
TweenSerivce:Create(Bar1,TweenIno,MinGoal):Play()
task.wait(0.1)
end
playing = false
end)
if its already visible when this script runs then im not sure why it wouldn’t run the loop. try putting a print statement inside the loop to see if it runs
while Bar1.Visible do
print('running')
TweenSerivce:Create(Bar1,TweenIno,MaxGoal):Play()
task.wait(0.1)
TweenSerivce:Create(Bar1,TweenIno,MinGoal):Play()
task.wait(0.1)
end
local Thread = coroutine.create(function()
while Bar1.Visible do
TweenSerivce:Create(Bar1,TweenIno,MaxGoal):Play()
task.wait(0.3)
TweenSerivce:Create(Bar1,TweenIno,MinGoal):Play()
task.wait(0.3)
end
end)
coroutine.resume(Thread)
---