This is hard to me to explain since this is hard to me, i have been working on my game, and the game is using some scripts from an Open-Sourced game (Shops, Game Round System, Etc.) and i was reading the Shop scripts and i got confused on something:
So, this is the script where identify when the player clicks on the pet to buy it and fire a server.
And this is the script where the player gets the pet.
So, my question is how does the script identify a player? Because the PetAdd event is sent with Buttons.Name, but how does the other script identify player and pet? If you want i can give you the full script.
if you look at the article it can give you a better understanding of this, but remote events can carry data over from the client to the server or the server to the client, so always the local player will be the first thing defined in the parenthesis.
When a player does an OnServerEvent the first thing the server gets in the message array is the player.
So the server gets 2 messages. First it gets who sent it. Then it gets the message. The connect(fire) passes the entries to the fire function.
Sending to the client is the reverse. You need to have it send (player, firstMessage) to tell the server who to send it to, and the player won’t get the player message, so it will just get the firstMessage.
Well Steve just gave you the solution, so it is not necessary, but somewhere in there, “Button” should be defined in that script, which is sending the pet data to the server. Steve literally made what I was trying to tell you simpler.