Table and client server questions

Hello,

I have two questions for u guys :

  • Lets imagine i have a playeradded event on the server and on the client. Does the event fires first on the server, waits to finish the function on the server and then fires on the client, or is it at the same time ?

  • What is faster between :

Tab1 = {
     a = 1, 
     b = 2, 
     c = 3, 
     o = 3, 
     p = 3, 
     u = 3, 
     y = 3, 
     g = 3, 
     h = 3
} --lets imagine this is a rly big table and not subdivided

and

Tab2 = {
     abc = {
          a = 1, 
          b = 2, 
          c = 3
     },  
     opu = {
          o = 3, 
          p = 3, 
          u = 3
     }, 
     etc = {
          y = 3, 
          g = 3, 
          h = 3
     }
} --lets imagine this is a rly big table as well but subdivided

What wd be faster between Tab1.a or Tab2.abc.a

Thx for your time :slight_smile:

1 Like

I am not sure how to answer your second question, but to the first question, you can test it.
Add a local script and print the player name when added, and do the same on the server, see what’s being printed first. The source of the print is your answer.

Note: make sure there is more than 1 player.

I actually don’t think there’s a difference in the second question, but not sure.

  1. PlayerAdded doesn’t fire on the client.
  2. I think the first one.

It doesn’t even fire on the Client (for the same client I meant) unless you somehow manage to defer its execution, since to do anything client-side you’d need a LocalScript - and LocalScripts are replicated to clients after the PlayerAdded event fires for said client, meaning the listener would be added too late.

It does fire, but only for other players that join after the local player. It just won’t reach the local player.

I tried such things in the past.

ha yea, forgot to say it, but i was talking about this, not for the local player

1 Like

Yes that’s right and I realized I’d need to clarify further right after I read my post, couldn’t edit anything because my internet left right after I posted that.
Though it was fairly obvious I was referring to the PlayerAdded event only for the client who joins, you can consider this as clarification.

For the first question accessing just one index should be faster than accessing through nested tables.

1 Like