Alternative variable access for each player that isn't in their character

Rn I’m too brain dead to think so sorry about that, but I had used a couple of important object variables in starter character. Then today I saw that those objects could be deleted locally and mess things up by reading the devforum.

What I want is for multiple scripts to be able to access these variables, while these variables are safe and unalterable by bad actors.

So what should I do?

1 Like

You can put your variables in a server script in ServerScriptService and if you want the client to read through the variables you can make a remote event or remote function and connect it.

But you also said you want multiple scripts to access these variables so you can put the variables in a ModuleScript and then require the module on the server to handle the variables on a ServerScript. Then you can make a remote event/ function and connect it to a local script that reads the variables.

1 Like

would each player have their own variables using module scripts, or is it global? Sorry if it seems like a simple question, I just want to make sure

1 Like

It is global. So each player would not. You can always put the server-sided script in StarterPlayerScripts Though. StarterCharacter service any scripts you put in there will go the the characters model which is easily exploitable sense the scripts in their replicates(goes) to workspace. StarterPlayerScripts is more safe

1 Like

Could I also just put the object variables in starterplayer to avoid them being deleted or is there no getting around that?

1 Like

Put the object variables in someplace people cant see. ServerScriptService, ServerStorage. Though if it has to be in starter player or starter character than just move the script you have to starterplayer sense if a exploiter did get a hold of it whatever they change would change just for them.

I would strongly suggest learning about modules and remote events/ remote functions

https://create.roblox.com/docs/scripting/scripts/modulescripts

https://create.roblox.com/docs/scripting/networking/remote-events-and-functions

Its gonna be very useful for dealing with what you are talking about. And give you knowledge on how to make scripts secure

1 Like

Thank you, I’ll try this tomorrow when I’m mentally refreshed.

2 Likes

All you need to do is have a server script that set attributes or values on the player then all clients can see them and read them if needed but cant change them. All server scripts can read and write to them if needed. You can also connectproperty or attributechanged signals to update server and client info

1 Like