#Problems when sending data with bindableEvents

1 messages · Page 1 of 1 (latest)

astral crescent
#

Hello, Basically the error is when a players joins it shows that the server give the original data correctly to the client, and the clients shows it right on the console, but in the game isnt right, In the code you can see more.
When a player joins, the server sends a RemoteEvent to the client to assign a camera focused on that player's base.
The problem is that when more than one player is in the game, the previous players' cameras change and point to the last player who joined.

Maybe the problem is with ModuleScripts.
I use a ModuleScript to store all the data for each player when they join. After that, I send it from the main script using a RemoteEvent. Here are the steps of the algorithm:

1-A player joins, and the DataStoreScript retrieves all the data for that player.

2-The data is stored in the ModuleScript.

3-The DataStoreScript uses a BindableEvent to notify the MainScript that the player is ready.

4-The MainScript sends the player’s data to the client using the ModuleScript, like this:
(PlayersData is the moduleScript name)
PlayersData[player.UserId]

5-The client receives the data sent by the server and sets up a GUI button that, when clicked, makes the camera focus on the player’s base.
(The client prints the correct data, and everything seems fine — but the camera always ends up pointing to the last player who joined.)

So, I don’t know what to do. Here is the code, friends.
Any help would be greatly appreciated.

Here is the code
https://sharetext.io/5319e5a8

ShareText is a simple way to share text and code with others for free online with Markdown support.

astral crescent
#

Sent: -1 To client with base: Base1 - Server - Script:242
Sent: -2 To client with base: Base2 - Server - Script:24

This is what the console of the server says, but in the client the player " -2 " has set its camera to the base of player " -1 ", but the player " -2 " was sent with his own base the Base2 and the player1 too

#

I dont understand what is happening

#

This is the client of the player 2 its base is the right one but its camera points on the Player1

#

Here is the player 1, its camera is on its base

#

Here is the print of the Client of the player two
Base2 - Client - CameraModeGui:63
CameraPart Base2 Player2 - Client - CameraModeGui:69

#

And the print of the Client of the player one
Base1 - Client - CameraModeGui:63
CameraPart Base1 Player1 - Client - CameraModeGui:69