Make server wait for localscript to load

Hi,
Summing the topic up, I want to be able to somehow wait for a localscript. The localscript is located in StarterGui. All I am doing is sending an remote event containing data to a localscript.

--SERVER
PlayerManager.CharacterAppearanceLoaded:Connect(function(player)
	print(os.clock())
	CaseInfoRemoteEvent:FireClient(player, rarities, cases)
	ItemsInfoRemoteEvent:FireClient(player, items, rarities)
	InventoryInfoRemoteEvent:FireClient(player, PlayerInventory.GetInventory())
end)

I’ve also put print(os.clock()) inside the localscript. The problem is that the server fires the event before the localscript is even loaded

  19:43:49.008  2095.0324194  -  Server - Server:63
  19:43:49.151  2095.1759548  -  Client - Arsenal:19

What I could do is just add a task.wait(5) which would work, although when using local server test (as I am developing the project with my friend), this won’t work, it would have to be like task.wait(30) which is not that optimal. Another possible solution would be just to move the localscript to ReplicatedFirst and everything would work very well, but that’s why I wrote this post because I would like to keep the localscript inside the startergui. Best solution would be to somehow make the server wait for that localscript to load.

Have the local script drive the request, either by invoking a remote function call to the server or firing an event that the server responds to by firing these events.

Or, have the remote receive a request from that LocalScript, and only then send the data to the client.

You shouldn’t be relying on the server for timing when it concerns a client’s loading times. You should have the Client tell the server when it’s ready, not the other way around.

Alright both your and @CantBeBothered reply make sense, I will do this with a remote function instead

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