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’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.
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.