I currently have a table with different numbers inside (server-script - ModuleScript).
It kinda looks like this:
local Table = {
[1] = {
Test = 12345
}
}
Just to clear up: Yes, I am currently using a RemoteEvent for this.
The issue starts when I would like to transfer that data over to the client (Table[1]).
Since the client is not able to see this it’ll return nil, and I don’t feel like replacing a script with StringValues / other objects just to send its content to the client.
What would be the best way to send over this information (without placing the script anywhere but ServerScriptService, as I don’t want exploiters to read the code)?
I have a few solutions in my mind, however I wanna see if anyone else has a better solution.
Perhaps a hacky solution to somehow send the value within the script to the client (?)
There is no other secure way to send data rather than using remote events. You can pass a table with the signal. However, if the module script contains a table that doesn’t change (values that are constant), you could separate module with the data and make the module accessible to both parties by putting it in ReplicatedStorage.
I know this may sound like a stupid response, but did you try putting that table entry into a variable and sending it to the client instead of a direct reference to the table?
Of course tables are passed as well. However, you can’t fire remotes from module scripts individually, as you first have to require them in order for them to start executing.
EDIT Yes, and I told you that you can either share a module script in case table values are constant. If that is not the case, you can freely transfer the table using remote events. Pass the whole table or part of the table correctly and the client will accept it.
Just like @HugeCoolboy2007 said as well, any table can be sent (unless it’s extremely large in size). I understand your issue. And both of us would like to tell you that you can require a module, and send a table (or part of that table) with remote event. You probably have your table stored this way:
local module = {}
module.YourTable = {}
return module
-- Server script:
local module = require(script.ModuleScript)
local yourTable = module.YourTable
You have at least two ways to send the table with module script.
From server script:
local module = require(script.ModuleScript)
local yourTable = module.YourTable -- send this table
by calling a method
function module.SendTable()
-- send from here
end
-- Server script
local module = require(script.ModuleScript)
module.SendTable() -- send the table
The client will not accept it because it will return nil as the client cannot see the table.
EDIT
You don’t get what I’m talking about.
The table is stored inside the modulescript, not where the event is fired as that is a completely different script, but the modulescript is required.
What does the client script look like when it’s receiving the table and what does the module script look like when it sends the table?
In order for the table to be nil, there has to be either values stored in the table that don’t replicate or the way it’s being sent/received is incorrect
Sadly that’s the issue, a hacky solution would be to create a object to store the number in, then send the object’s value to the client, might as well do that.
And no, nothing within SSS is replicated to the client, ever.
Neither ServerStorage as those services are server-sided only.