Loading Circle Issue

So I have made a loading circle. It is a basic decal. What I want it to do, is when the GUI is enabled, the loading circle starts and goes for about 5 seconds. and then it fades into some text. The problem is, after about 1 second, it just stops. And it does not fade into text at all. Can you guys help me?

Script:

local Background = script.Parent.Parent

script.Parent.Background.TextButton.MouseButton1Click:Connect(function()
	local gui = Background:FindFirstAncestorOfClass("ScreenGui")
	gui:Destroy()
end)

while wait() do
	game.TweenService:Create(script.Parent.Background.ImageLabel,TweenInfo.new(1.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Rotation=500}):Play()
		wait(1)
		while wait() do
			script.Parent.BackgroundTransparency = script.Parent.BackgroundTransparency + 0.08
			script.Parent.Parent.BarBackground.BackgroundTransparency = script.Parent.Parent.BarBackground.BackgroundTransparency + 0.08
			script.Parent.Parent.LoadingText.TextTransparency = script.Parent.Parent.LoadingText.TextTransparency + 0.08
			
			if script.Parent.BackgroundTransparency >= 1 then
				script.Parent.Parent.AfterText.Visible = true
				wait(1)
				script.Parent.Parent.Done.Visible = true
				script.Parent.Parent.TextButton.Visible = true
			end
		end
end
		
		
		

Thanks in advance.

Hello. Can you show us video what is that script doing ?

Its because the tween doesnt make the script wait until it finishes.

2020-07-31-11-42-55

Im not sure I understand. Do you mind fixing the script for me?

What I meant is the code will keep on going and wont wait for the tween to finish like this:

game.TweenService:Create(script.Parent.Background.ImageLabel,TweenInfo.new(1.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Rotation=500}):Play()
print("Ok")
-- It will print ok even if the image didnt rotate completely.

So should I use that line of code instead of my current?

No? I just explained that the code will keep on running even if the tween aint completed

And if you are going to do it for 5 seconds then you should put 5 instead of 1.5 in that tween.

So what do I do to make the script wait before it fades?

You could make the Tween into a variable, play it, then wait for the .Completed event to fire.

local tween = game.TweenService:Create(script.Parent.Background.ImageLabel,TweenInfo.new(1.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Rotation=500})
tween:Play()
tween.Completed:Wait()
-- rest of code
1 Like

Hey so I am trying to get the stuff to fade but I keep getting an error saying “ImageLabel is not a valid member of ImageLabel.” Can you tell me why?

local tween = game.TweenService:Create(script.Parent.Background.ImageLabel,TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Rotation=500})
tween:Play()
tween.Completed:Wait(1)
		while wait do
			script.Parent.Background.ImageLabel = script.Parent.Background.ImageLabel.ImageTransparency + 0.08
			script.Parent.Parent.LoadingText.TextTransparency = script.Parent.Parent.LoadingText.TextTransparency + 0.08
			
			if script.Parent.BackgroundTransparency >= 1 then
				script.Parent.Parent.AfterText.Visible = true
				wait(1)
				script.Parent.Parent.Done.Visible = true
				script.Parent.Parent.TextButton.Visible = true
			end
		end
		
		
		```