Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Where do i store a number value?

2 answers

You never quite explained what you are doing. You want to have one number value in storage that all clients use? That's interesting, but as you read in the forum, it is extremely insecure. Anyone can change the value at will and the server will have no idea. It is much better practice to have the values stored inside a server script or ServerStorage, then use RemoteEvents to let the clients know their values.

If you really don't care about exploiters...

ReplicatedStorage is for objects you want both the client and server to see. ServerStorage is for objects you only want the server to see.

So in this situation you'll want ReplicatedStorage.

It sounds like you might want to have a separate value for each player. In this case, you should look at how the standard leaderboard script works (you can find it in the Roblox Studio's Toolbox under "Roblox Sets", "Game Sets") - it gives leaderboard values to each player, which are automatically removed when the player leaves (since they are parented to the player). You needn't have them show up in the leaderboard, but the same idea would work.

Of note, if you don't have FilteringEnabled, someone could theoretically change everyone's values, not just their own.

Another method, if FilteringEnabled is enabled, is to have a single NumberValue (or IntegerValue or whatever you need) under ReplicatedStorage. If only LocalScripts modify this value, then the value changes will only apply to the client whose scripts modified it. However, a Script would be unable to get the "correct" value without asking the Client for it (via a RemoteFunction) and if any Script attempted to change the value, it would change it for all clients, regardless of what value each client previously had for it. You could avoid these problems by creating the IntegerValue on the client (which you would do in a script during run-time) rather than putting it in ReplicatedStorage.

You could also just use _G, which is a table that is global between all scripts on the same client or all scripts in the server. Again, communication between LocalScripts and Scripts would have to occur if they both needed the value of that number.

This discussion is preserved as it was. New answers, comments, and votes are closed.