How to get a server side Value's value in local script?

Sorry that the title may be confused

As I know, a Value’s value can differ on the server and client sides and the exploiter may change the value to cheat in the game.
So I am trying to get a value from the server side in the local script.
I don’t know if this is easy to do. The only way I found is by using the RemoteEvent to get it but for some reason, I don’t want to use it.

If you are still confused by my question, here is an example.
↓↓↓
On the server side:


The value of the MaxAmount of this apple is 10.

But on the client side:


The value of the MaxAmount of this apple may be changed to 100.

Now if my local script uses the value of MaxAmount directly, my local script will get 100 but what I want is 10.

Server cannot see client changes, but it can anticipate events occurring in the game. You can track the stats on server and monitor if an event being fired. If the client tries to do something that is impossible, the server won’t process their events the normal way.

1 Like

Thanks for your answer.
But what kind of things are impossible that the client will do?
Does it mean maybe set that value to a huge number?
What if the player just changes the value of Amount and the value changed is smaller than the MaxAmount?

Tbh you shouldn’t waste your time trying to protect minor data values like that on the client, as you shouldn’t be trusting client data to begin with. As long as you do checks on the server-side before performing actions you should be fine.

1 Like

No matter what you do, the client will be able to change this value to 100 and get unexpected results on the client. What you should do is code your game so that this has no exploitable impact on their gameplay.

For example, it’s totally okay if the client cheats their apples’ maxAmount to be 100 if their inventory now displays “Apples (X/100)”. This is just the interface doing its job with the data it’s given. However it wouldn’t be okay if this actually allowed them to carry more than 10 apples. For that reason, the server should always check that the client actually has room for more apples before giving them another one.

1 Like

Thank you for your answer, I will try.

Thank you also for answering my question.

1 Like