Problem In Loading Screen Script

So, for practice, I am making a loading screen script. I’m a fairly new scripter so I’m not good at scripting yet, I just know the basics. In the script, I am trying to make it start from number 1 and then go to 100. There’s a bar at the bottom too with color, so it turns a bit bluer at each number.

The problem with the script is that it will not close after it is done. The code “script.Parent.Parent.Parent:Destroy()”
I added should have destroyed the script’s parent’s parent’s parent (which is the screenGUI) but it didn’t, and it just stayed at the screen.

This Is the screen it stays at;


I can provide all the scripts I used if it is needed for you to help me solve this issue. Help is appreciated.

Thanks.

Would you mind providing an output log?

In addition to @snorebear’s request, I’d like to see the full script.

Do you want a screenshot or can I paste it here?

Yep. I think it seems alright;
image

Either or should work. Though I’d recommend pasting.

Okay, I made 2. Here’s the main one;

local BarProgress = 0

while wait() do

BarProgress = BarProgress + 0.5

script.Parent.Size = UDim2.new(BarProgress/100, 0, 0.1, 0)

script.Parent.Parent.LoadingText.Text = ("Loading... "..math.floor(BarProgress*2).."%")

if BarProgress == 50 then
	
	game.Workspace.Ding: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
		script.Parent.Parent.BackgroundTransparency = script.Parent.Parent.BackgroundTransparency + 0.072
		
		if script.Parent.BackgroundTransparency >= 1 then
			
			script.Parent.Parent.Parent:Destroy()
			break	
		end	
	end
end

end
And the other one
script:WaitForChild(“Loading”):Clone().Parent = game.StarterGui

You’re adding 0.8 each time it loops and Roblox only goes until 1. So the background transparency reaches 0.96 at the max. I don’t think it would go over since 1 is the max. Could you try using something like 5 or 10.

Edit: Nvm I am wrong

Have you checked to make sure the BackgroundTransparency has reached 1? Since looking back at the picture, nothing there is truly 100% Transparent. Unless it’s something else…?

How about instead of the if statement detecting BackgroundTransparency, it detects if the BarProgress variable is equal to 100? I think that’s a more reliable way of checking if the screen is complete rather than checking the transparency.

Do you mind posting the hierarchy?