I'm making a game that uses a table which contains a lot of information that needs to be used by other scripts(on both server and client). I would normally use a ModuleScript for this, but since this table can be changed by a script(both on server and client), I'm not sure if this is the best thing to do.
So, the question is either "does the table in a ModuleScript update automatically over both server and client", "how do I make the table update over both server and client" or "Is there a better way to go about this"?
What the best thing to do would be to store all your information in a Library (which is a type of table) inside of a Module Script
on the Server Side. The Server is the best place to store this type of information because it's more secure from exploiters rather than keeping it completely visible and view-able on the client.
A Module Script
takes the whatever side you put it on, Server or Client. ReplicatedFirst would be Client while ServerScriptService would be Server.
To access it from the client, you would want to use a RemoteFunction
to Invoke the server and return the data you need.
Example...
Library
local data = { sword = {damage = 5, cooldown = 1}, bow = {damage = 10, cooldown = 1.5} } local module = {} module.getData(object) -- Where object is a string return data[object] end return module
LibraryConnector Script
local LibraryConnector = game.ReplicatedStorage.LibraryConnector local Library = require(game.ServerScriptService.Library) local function onDataRequested(player, object) return Library.getData(object) end LibraryConnector.OnServerInvoke = onDataRequested
Client Local Script
local LibraryConnector = game.ReplicatedStorage.LibraryConnector -- RemoteFunction local swordData = LibraryConnector:InvokeServer("sword")
Helpful link for understanding... Remote Functions/Events