How do I change a value in the player's Backpack?

I feel like this has a very simple answer, but for some reason I can’t figure out how to change a number value in the Local Player’s Backpack. I made a simple script in a Click Detector, but it just won’t work. What am I doing wrong?

os.time()

script.Parent.MouseClick:Connect(function()
	local num = math.random(1, 500)
	game.Players.LocalPlayer.Backpack.TESTVALUE.Value = num
end)
1 Like

cant you put your “TESTVALUE” somewhere else in the player? because im not sure if its possible to store values in the backpack

I know it’s possible, I just can’t seem to do it.

I just tried it and no its not possible, the devhub page shows that it can only store “Tool” Instances, so just place your “TESTVALUE” somewhere else in the player and it’ll work! :thumbsup:

Where could I put it then? Should I create a new folder or is there somewhere else I’m supposed to put values in the player?

just put it in the player instance

Is this a Script or LocalScript? If it’s a Script, LocalPlayer is nil.

Also, backpack children get cleared every time a character loads, which may cause your value to be deleted when the player first loads their character in or reloads it.

are you sure about that? because i dont think its relevant to the character resetting