Wait for client to load before firing event

I have this event that’s fired off hundreds of times a second when a player joins. It basically spawns in individual pieces of trash for them.

self.Client.SpawnTrash:Fire(player)

However, I keep getting

Remote event invocation queue exhausted for ReplicatedStorage.Packages.Knit.Services.TrashService.RE.SpawnTrash; did you forget to implement OnClientEvent? (32 events dropped)

How can I wait till the client has loaded fully first, without putting trust in the client to actually return something?? Be purely server side

Can’t you do something like SpawnTrash:Fire(player: Player, amount: number) so that it only fires a single event for multiple trash.

You could fire the same event from the client first, and then on server end fire it back. So that the client decides when to ask for the trash to spawn.

Not really viable, as when a single piece of trash is collected, it automatically needs top fire again. Would be a nightmare to have several remotes handle either spawn all trash, spawn specific trash etc. This remote basically gets fired if their trash < a threshold number.

If the server waits for the client to send something, they may never send it

Your error doesn’t have anything to do with client being loaded. It says that you are firing the event too many times. You need to reduce the number of times it fires in a second, or better yet, as suggested above, fire it once and start spawning whatever by firing only once.

And as I mentioned in my reply, I can’t just fire it once. The error is relating to client not being loaded, as when the clients loaded, I can fire a remote off every task.wait() with no issues. It’s only cause the client has loaded and the listener hasn’t loaded that that error occurs

you can wait for the script wherever OnClientEvent is written. In your script where you are firing the event do

player:WaitForChild("Your client script name")

P.S. If you can not do it without firing it once, your code is extremely bad and it is gonna cause major performance issues with many players.