Save instances in tables as indexes

I want to save instances properly through tables as indexes, ex: CharacterTable[Character] = 100

image

The issue, however, is that it puts the index as above ^ Instance (instancekey). When I try to call upon it using a for char,value loop, it thinks that the char is a string. How would I save it?

(Using Character since i want to save rigs)


game.Workspace.ChildAdded:Connect(function(child) -- obviously there are checks that make sure it has a humanoid etc.
local CashAmt = math.random(100,350)
	
	CharacterCash[child] = CashAmt
end)

If you’re trying to save it through a datastore, that will not work. Also, if you’re printing it and it is printing as a string, I am quite sure that is normal and you can just ignore that unless it is genuinely not retrieving when using the character to try and fetch it using CharacterCash[Character].

It is not for a datastore. I am trying to show the cash amounts for a certain client.

Then I’m mostly sure that there shouldn’t be an issue unless you aren’t able to get it out of the table using CharacterCash[Character]. Again, printing the name of the object is a normal thing if that’s what is happening.

Its not the printing that is the issue. I am getting a instance expected, got string error when I use a for loop.
*Shortened but it does contain me creating the highlight, etc.


for newChar,Money in pairs(CharacterTable) do
newHighlight.Parent = newChar
end