Server Values are Nil on Client?

I’m having some issues with values within my module script.
Ideally, I’m looking to edge away from creating physical values in-game and instead transferring the required data between the module scripts themselves.

The issue I’m having is that once created as an Instance within my core ModuleScript, when transferred to the client through a RemoteEvent it returns as a nil value.

The example below is basic, yet self explanatory - Any help on this will be greatly appreciated.

Example of this:
ModuleScript:

local module = {}
local ValueA = Instance.new("StringValue")
ValueA.Value = "Test"
script:WaitForChild("RemoteEvent"):FireAllClients(ValueA)
return module

LocalScript:

local Player = game:GetService("Players").LocalPlayer
local RemoteEvent = game:GetService("Workspace"):WaitForChild("ModuleScript")["RemoteEvent"]
RemoteEvent.OnClientEvent:Connect(function(ValueA)
print(ValueA.Value)
end)

The reason why you are getting this problem is because you are attempting to send an object over to the client. The way to fix this is by sending the StringValue’s value directly. Here is your code fixed:

local module = {}
local ValueA = Instance.new("StringValue")
ValueA.Value = "Test"
script:WaitForChild("RemoteEvent"):FireAllClients(ValueA.Value) -- Changed to the value
return module
local Player = game:GetService("Players").LocalPlayer
local RemoteEvent = game:GetService("Workspace"):WaitForChild("ModuleScript")["RemoteEvent"]
RemoteEvent.OnClientEvent:Connect(function(ValueA)
print(ValueA) -- Prints the value sent
end)
2 Likes

Thank you!

My main purpose for this is that the CoreModule will manage these values - They will be updated ServerSide. This is all for a SpaceShip that will be piloted Client-ly, so it will need to check the Value has changed within the CoreModule.

I understand this would have been 100x easier if I had chosen to just use the physical values.