How to know once everythings finished in script?

So i use datastore 2, which takes a module full of stats and loads them in, but I wanna know how to tell when everything has finished loading in, any help?

local DataStore2 = require(1936396537)

local Settings = require(game.ReplicatedStorage.ModuleScript)

game.Players.PlayerAdded:Connect(function(plr)
		for i,v in pairs(Settings) do
			local datastore = DataStore2(i,plr)
			local where = v.Where
			if v.Where ~= "Player" then
				if plr:findFirstChild(v.Where) then
					where = plr[v.Where]
				else
					local folder = Instance.new("Folder",plr)
					folder.Name = v.Where

					where=folder

				end
			end

			if v.Where == "Player" then
				where= plr
			end
			--// Creates the Value
			local val = Instance.new(v.What,where)
			val.Name = i
			val.Value = v.Value

			--// Loading
			if datastore:Get() ~= nil then
				val.Value = datastore:Get()
			end

			--//Saving
			val.Changed:connect(function()
				datastore:Set(val.Value)
		end)
		end
	end)

or is there a way to rearrange it so i could?

fire a bindable event at the end of the script. and when you receive it it another script, it says the script has come to an end

How would I go about doing this? Because im trying to convert this intro an event that fires from the intro, and once its all loaded i want it to send an event back saying its finished loading it all in

so iv put this together, it receives the first event and loads everything, but wont send the last one once its all loaded, any help.


local DataStore2 = require(1936396537)

local Settings = require(game.ReplicatedStorage.ModuleScript)

local gui = nil

game.ReplicatedStorage.Remotes.ToDatastore.OnServerEvent:Connect(function(plr,gui)
	print("got first event")
	gui = gui
		for i,v in pairs(Settings) do
			local datastore = DataStore2(i,plr)
			local where = v.Where
			if v.Where ~= "Player" then
				if plr:findFirstChild(v.Where) then
					where = plr[v.Where]
				else
					local folder = Instance.new("Folder",plr)
					folder.Name = v.Where

					where=folder
				end
			end

			if v.Where == "Player" then
				where= plr
			end
			--// Creates the Value
			local val = Instance.new(v.What,where)
			val.Name = i
			val.Value = v.Value

			--// Loading
			if datastore:Get() ~= nil then
				val.Value = datastore:Get()
			end

			--//Saving
			val.Changed:connect(function()
				datastore:Set(val.Value)
		end)
	end
	local typeofe = "StartIntro"
	gui.Event:FireClient()
	print("sent 2nd event")
end)