Table has no data after it's sent to client

Everything prints what it needs to on the server but on the client only the value prints right, the table is empty for some reason. Am I doing something wrong with passing arguments?

server

game.Players.PlayerAdded:Connect(function(player)

	local stats = game.ServerStorage.PlayerData:WaitForChild(player.Name,30)
	
	local rollableTalents = {}

         for i,v in pairs(stats.RollableTalents:GetChildren()) do
		table.insert(rollableTalents,v)
         end

	Rank:GetPropertyChangedSignal("Value"):Connect(function()
		CardPulls.Value = CardPulls.Value + 1
		
	end)
	
	
	local value = CardPulls.Value
	
	if CardPulls.Value > 0 then
		svRemote:FireClient(player,value,rollableTalents)
	end

	CardPulls:GetPropertyChangedSignal("Value"):Connect(function()
		value = CardPulls.Value
		svRemote:FireClient(player,value,rollableTalents)
	end)

end)

client

svRemote.OnClientEvent:Connect(function(value, rollableTalents)
	print(value)
	for i,v in pairs(rollableTalents) do
		print(v)
	end

end)

Could you post the output you got from the client? I know you said the table is empty, but it’ll help with visualizing the problem.

Also, this is just a guess but when you fire the remote as soon as the player joins the game, their data might not have loaded yet which could explain the empty table.

you can’t pass objects from sss/server storage to client. the client can’t “see” them.

5 Likes

server
image

and client
image
4 is the value but the table’s empty

yeah thats why im making sure im not sending them directly, and number works its just the table

On the server script, can you do

local rollableTalents = {}

for i,v in pairs(stats.RollableTalents:GetChildren()) do
     table.insert(rollableTalents,v)
end

print(rollableTalents)

and post what you get to make sure the table isn’t empty when you send it? If its not empty, I’m not really sure what is causing the problem…

You’re not, that’s now how instances work. You’re sending a reference to the object. “This object is located here.” Since the client can’t access it and it doesn’t exist on the client, “this object is located here” has no meaning. Move the stats to ReplicatedStorage, or don’t send full instances to the client.

2 Likes

Do you have any idea on how should I go about this? Im trying to make sure that it wont get exploited so Im trying to send data from server to client then client to server to do the checks, but Im not sure on what to use, should I continue with events, or do you have any ideas I could look into?

Just put it in replicated storage, it can’t be hacked there except on the client locally. You’re already trusting the client with the data when you send it to him, so keeping it there won’t make it less secure.

1 Like

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