Is there any way to make values not replicate to clients?

I noticed that when you insert values into workspace and change them in a ServerScriptService they will replicate to all clients. I’m trying to make the server only know the value and I don’t want my values to replicate to clients.

For example:

local Value = workspace:WaitForChild("NumberValue")
task.wait(5)
-- Change the value

-- This is done on a serverscript so it replicates to all clients all I want it is to not replicate to any clients at all.

Value.Value = 100
1 Like

Put the values in the serverstorage

1 Like

I don’t want to use remote events I’m trying to make them not replicate at all

This would be a good idea but how would this work if you put values inside a model? My values need to be stored inside a model and they replicate

You could take advantage of _G, which is a global table, independent on client, server, and corescripts.

-- Server:
_G.Test = true
print(_G.Test) --> true
-- Client:
print(_G.Test) --> nil

Can’t you just use shared on the server?

Yes, shared works too. From what I know it has the same function as _G.

Alright! Thanks for this it will be very useful to reduce server lag

1 Like

Sorry, but can you explain me what _G is? Is it table local tbl = {1, 2, 3...} or it smth else?

It is a table but it’s the same one for every script, but seperatly on Client, Server, CoreScripts, and technically exploits too.

Just curious, how is using _G different from simply storing the value in ServerStorage? Both are placed somewhere away from your model

AFAIH both _G and shared should not be used because of possible race-conditions where one script loads before another, causing the value to potebtially not be set yet

I suppose if you want that value to be linked under the model, you could place a NumberValue or StringValue or whatever in ServerStorage, then place an ObjectValue in the Model with its Value set to the NumberValue so that it can be accessed from other server scripts.

_G is still a perfectly valid approach though I do recommend you use protection against race-conditions. I.e.

-- Script 1
_G.MySecretValues = {}

....
-- Script 2
repeat task.wait() until _G.MySecretValues

_G.MySecretValues.ABC = 123

(BTW do not unmark blueberry’s answer as solution, not that I think you would.)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.