LoadCharacter takes ages to run

Hi there!

I’m creating a custom loading screen for my game, and everything’s working great. I got a loading bar, the UI looks nice and everything. The small problem is that when the player clicks “Play!” on the menu, their character takes ages to load.

I’m using a RemoteFunction to tell the server to run the “LoadCharacter” function on the player (I’m using a RemoteFunction deliberately to yield the local script) and the server is receiving this connection.

From here, I print “Connected” and then immediately run the LoadCharacter function.

After 5 long seconds, the character is loaded and the script continues. I measured this by printing “Loaded” directly afterwards and the timestamps in the output are 6 seconds apart.

Is there any way to speed this up?

Thanks,
-Tom :slight_smile:

CLIENT SIDE

local Clicked = false -- Debounce
UI.Frame.Play.MouseButton1Click:Connect(function()
	if not Clicked then
		print("Clicked")
		Clicked = true
		ReplicatedStorage.Remotes.LoadCharacter:InvokeServer()
		ReplicatedStorage.Remotes.LoadCharacter:Destroy() -- To stop this function from being used again
		UI:Destroy()
	end
end)

SERVER SIDE

  10:25:03.854  Connected  -  Server - WorldSetup:10
  10:25:08.508  Loaded  -  Server - WorldSetup:12

game.ReplicatedStorage.Remotes.LoadCharacter.OnServerInvoke = function(Player)
	print("Connected")
	Player:LoadCharacter()
	print("Loaded")
end

Only reasons I can think of are lag and/or bugged.
Also, for security reasons, I recommend server-side checking if the player has initially loaded already instead of destroying the remote.