I’ve been practicing to store variables and data on scripts and avoid storing them on Instances such as BoolValue, NumberValue, ObjectValue, ColorValue, Etc. So I really want to know if it is safe to store variables and data on these Instances.
What I Know
Security Depends on the Value Object’s parent (ServerStorage, ServerScriptService, Etc.)
Value Objects have a .Changed Event
Value Objects can be read and accessed by the client and server (if replicated)
What I Think I Know
Variables in scripts are safer and can’t be read or modified by the client or server directly
What I Want To Know
When do Value Objects actually come in handy?
Is it safe to use Value Objects?
I’m not a die hard developer yet, so I don’t actually use these things
The only security issue I can see is the client seeing vital information held by the server, if exposed through replication of data-storing objects. Other than that, it really comes down to good practice in programming; data-storing objects are generally avoided since they’re more or less useless.
Data can be stored in regular variables or tables, and can be associated with an object through use of certain data structures; for example, a dictionary:
-- associate 10 apples with a player object style
player.Data.Apples.Value = 10
-- associate 10 apples with a player dictionary style 😎
playerData[player].Apples = 10
-- get apples of a player object style
local apples = player.Data.Apples.Value
-- get apples of a player dictionary style 😏
local apples = playerData[player].Apples
With that being said, I do find myself using data-storing objects sometimes. There’s no real need to go out of your way to avoid using them—it just seems odd to have Instances dedicated towards storing data.
Only the local player will see the values that are changed. Other players won’t be able to see it. I store my values in ReplicatedStorage and haven’t had any issues with clients changing values. Since it’s Filtering Enabled in all games, automatic replication from client > server doesn’t happen anymore
If you want to store your data in such a way, go ahead. I personally see it as too difficult to handle, and using a table means you can get it directly from a data store and store it directly back into the data store without having to change the structure of the data. Just my two cents.
Problem with storing data in ServerStorage is really only being able to get the data via remote events from a client script. As long as you handle data on Server correctly you’ll be perfectly fine storing it mostly anywhere