How would I check for when a for i loop is done?

I am trying to make it where when the character spawns, it adds all the neccesary scripts to the player.
I want it to make a GUI pop up that says “Loading complete.” when all the scripts are in the player’s character…

This is what I have so far:

local plr = game.Players.LocalPlayer




plr.CharacterAdded:Connect(function(char)
	if char then
		for i,v in pairs(script:GetChildren()) do
			if v:IsA("LocalScript") or v:IsA("Script") then
				local clone = v:Clone()
				clone.Parent = char
				wait(0.5)
				clone.Enabled = true
			end
		end
	end
end)

I havent added the gui part yet, but I am planning to do so when I know how to check for when to show it.
Thank you!

after the for loop is when the for loop is done.

plr.CharacterAdded:Connect(function(char)
	if char then
		for i,v in pairs(script:GetChildren()) do
			if v:IsA("LocalScript") or v:IsA("Script") then
				local clone = v:Clone()
				clone.Parent = char
				wait(0.5)
				clone.Enabled = true
			end
		end
        print('done')
	end
end)
1 Like

im stupid, sorry! I am pretty new to for loops so thats why i didnt know this

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.