Core Scripts Loaded

How do you know when the core Scripts are loaded? Is there a method to check?

Core scripts will always load before any other code. Generally speaking, you don’t need to check if a CoreScript has loaded anyway.

You’re probably talking about SetCore, which isn’t always registered immediately. Here’s some code that will allow you to do this (feel free to tweak)

local StarterGui = game:GetService("StarterGui")

local MAX_RETRIES = 3
local RETRY_WAIT_TIME = 10

local function retry(method, ...)
    local success = false
    local message
    local tries = 0
    while not success and (tries < MAX_RETRIES)  do
        success, message = pcall(method, ...)
        if success then
            break
        else
            wait(RETRY_WAIT_TIME)
        end
    end

    if success then
        return true
    else
        error("Failed: ".. tostring(message))
   end
end

retry(StarterGui.SetCore, StarterGui, "ResetButtonCallback", false)

For me at least, this code is rather trivial. Feel free to let me know if you’d like me to explain it in detail.
Hope this helps!

2 Likes
retry(StarterGui.SetCore, "ResetButtonCallback", false)

should be

retry(StarterGui.SetCore, StarterGui, "ResetButtonCallback", false)

Otherwise, good example :slight_smile:

1 Like

Absolutely. I’ve updated my post, good catch.
as you can clearly see, i tested my code

You shouldn’t have a case in your game where you need to check when CoreScripts have been loaded and executed. Why do you need to check for this? Is it because of SetCore and how it doesn’t immediately register the options? Above method can resolve that.

3 Likes

Though as @colbert2677 correctly stated, there is absolutely no need to…
I came up with a server script in ServerScriptService to check when the game has loaded, and since nobody would want to do that, it just might not be the best way…
here’s what I came up with :

if not game:IsLoaded()then  return print("Not loaded yet..") end
	--additional check..for some reason I fail to understand
	local Total_Descendants=5392--you get this by running count.Value=#game:GetDescendants()while the game runs but you'll have to wait a bit and then close solo/test mode then the value should be the number of descendants (after you quit solo/test mode)
	local count = workspace.Folder.count
	local loaded = workspace.Folder.loaded
	
	function checkformore() 
		game.DescendantAdded:Connect(function()
			count.Value = #game:GetDescendants()--count descendants
		while count.Value<Total_Descendants
		  do wait(1.1)
            print("not fully loaded.")
              loaded.Value=false 
               if count.Value==Total_Descendants then 
	 print("fully loaded ")
end				
		
			
		checkformore()
	end)

Why do you have a completely empty function? Also, this code won’t run past the first return print("Not loaded yet..")

sorry about that error the script for some reason, does still work, might’ve put that in accidentally with the edit , it does still serve its purpose.
*I edited the post, should be fixed.
However I still don’t see the need for checking for them being loaded.