-
What do you want to achieve? Keep it simple and clear!
The leader board should be the same for all. -
What is the issue? Include screenshots / videos if possible!
You cant see the changes on the leaderboard for others except for yourself due to the code being in a local script. Should I use remote events every time a coin is touched to add to the int values in leaderstats on a server script instead?
This question is quite unclear but I will give it a go,
You should never add leaderstats through a remote event/local server unless you do a lot of checks on the server. For what I think your saying, you should use a server script for a leaderboard.
Sorry for being unclear, i want to know if adding to the int values inside leaderstats using a remote event is ok, would happen every time a coin is collected.
If you want the changes to the leaderstats to be visible to all players then the changes need to be done by the server.
Yeah, I really don’t recommend using a remote event to edit leaderstats. Use a server script to edit the leaderstats.
Coins spawn for the client and the touch event for the coins to disappear and add to the int value in leaderstats is also in player scripts. What should i do?
The server should really have some say in the coin spawning, even if it’s just to tell the client to spawn them in. The server will then have some information about whether a client has genuinely touched a coin or not.
Process flow something like this:
-
Server fires remote event to tell client to spawn coin with some unique identifier.
-
Client spawns in the coin and keeps track of which physical coin corresponds to which unique identifier.
-
Client touches coin and fires event to server with the unique identifier.
-
Server updates leaderstats and makes a note of the unique identifier so that each coin is only collected once.
Note that this is still far from flawless in terms of security as the client could just immediately fire the event with an appropriate identifier as soon as one becomes available.
If you can handle all of the spawning on the server you should, as this is more secure than the client side method I’ve suggested.
You don’t at all need remote events for this. Just handle it all on the server.
You only need this if you want the coins locally on the client side and not able to be taken by other players
I never said that remotes were needed. I even said that I suggest just doing it all on the server in my post?