When to Fire Client for Replication

When do you fire a player’s client for replication after they joined the game?

I’m doing it after characteradded but it’s not working. Maybe because i’m waiting for the signal in a client module script?

2 Likes

Could you elaborate on the issue and provide a bit more information? I’m not sure what you mean by “fire a player’s client for replication”.

2 Likes

Do you mean when they join the game? If you are waiting for them to load in, use game.Players.PlayerAdded:Connect()

If you are waiting for their character, CharacterAdded should be working just fin, regardless if the script is local or server.
If the issue is the latter, can you provide with the code that waits for the event?

2 Likes

Are we able to see your code as we will be able to help you easier.

1 Like

Replicating what?

2 Likes

I’m not sure what your use case is or what you’re replicating, but typically the rule of thumb is not to replicate unless it’s necessary. So either way, if you don’t need it replicated at that moment, then don’t do it. Don’t replicate things that don’t need to be replicated either.

Ok, so basically when the client joins the game, I want the server to fire a client event. But the client event has not loaded on the client yet.

When is it actually safe to fire the event?

Can’t you use :WaitForChild() for that?

No, it’s

EventName.OnClientEvent:connect(function()

on the client

but on the server it’s

Players.PlayerAdded:connect(function(player)
EventName:FireClient(player)
end)

before the client even got to the OnClientEvent part, if that makes sense

So… your problem is that the player hasn’t even loaded the event before it’s fired…? :confused:

yes, but i need the event to fire the newly joined player from the server

What is happening on the client after the server fires the remoteevent?

If I was you, I’d invoke the server from the client.

The client isn’t finished loading yet. I’m assuming the code is still being read/loaded/compiled or whatever it’s called.

Then invoking the server would work. It would happen when the client is ready.

1 Like

Would you say most games do it like this for new players joining to sync up things that are already existing?

Like player holding weapons (weapons are client sided)?

I would say most games don’t do it this way as the client is sending a message to the server and that could get exploited. The server is encrypted so people can’t exploit that so people run most of their code from the sever. The general rule is to never trust the client.

You got it wrong. It’s the other way around.

In simple terms you should never trust the client. Here is a post about exploits: Exploiting Explained. Here is a quote that is relevant to you:

To expand on what @C_onfident said:

I would put checks in place if you are going to do this method to check for exploits.

I was just saying you assume I was requesting something from the client.

It was the client requesting replication info from the server.