Hey there!
I am having some trouble with tables
My issues: My table is not showing the items in it correctly. It doesn’t seem to save correctly as a result of that.
Ok, I am going to try to explain this really well so it is going to be a little easier for people to understand and respond.
Explanation of first issue: When I join the game, my table prints in the output from the server using this code:
print(_G.petUpgradeAmount[player.userId])
And it prints this:
unimportant, I am uncertain how “1” and “2” got there
This is normal, and what I would expect it to print.
Every time a GUI needs that table information, in a local script of course, it needs to get it from the server.
It calls it through this line of code
local PetFunction = game.ReplicatedStorage:WaitForChild("PetUpgradeAmountRequest")
local Boost = PetFunction:InvokeServer()
The server then receives it and returns the table
local petUpgradeARequest = game.ReplicatedStorage:WaitForChild("PetUpgradeAmountRequest")
function onPetUpgradeARequest(player)
while (_G.petUpgradeAmount[player.userId] == nil) do
wait(0.1)
end
return _G.petUpgradeAmount[player.userId]
end
petUpgradeARequest.OnServerInvoke = onPetUpgradeARequest
That was all working grand and everything until a couple days ago, where it does seem to have enough information.
So I went to go print the table from the client to see what the problem was using some of the code up above:
local PetFunction = game.ReplicatedStorage:WaitForChild("PetUpgradeAmountRequest")
local Pet = script.Parent.Name -- the name of the gui this script is in is = one of the items in the table, for instance the "Default Pet"
local Boost = PetFunction:InvokeServer()
print(Boost[Pet], Boost)
I wanted to print the actual item with Boost[Pet] and the whole table with Boost, and I get this!
That is all there is!!! Like there is nothing else in the whole table!
I am certain that the information was not delete because at the same time, another server script that is connected to the actual pet and is calling the table as well via another method and it is printing the whole thing.
Conclusion: I know that was a lot, but I really am just stumped on why it is not working! I would really appreciate it if someone can help me find the solution. Thanks! If you need me to explain something more just ask!
Note: I am not going to try and explain the second issue, because I am guessing that will be solved when the first issue is fixed, but if it doesn’t then I will explain it.