Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my object disappearing from ReplicatedStorage?

Hello, I tried doing a script to save datas on a table but something weird happens

a part of the script:

game.Players.PlayerRemoving:Connect(function(Player)
	local StatsValue = {}

	for _,v in pairs(game.ReplicatedStorage.Stats:GetChildren()) do
		print(v.HasGot.Value)
		local New = {['Material'] = v.Name, ['HowMuch'] = v.Value, ['Unlocked'] = v.HasGot.Value}
		table.insert(StatsValue,New)
	end
end)

And the value is actually printing "false" but when I want to insert it in "Unlocked" i get the error "HasGot is not a valid member of StringValue"

I don't understand why :(

1 answer

Well, I am not sure what is causing the HasGot not the member of StringValue. But, other from that, there is a major issue. You cannot add Dictionaries to the table using table.insert. the following code might help :

game.Players.PlayerRemoving:Connect(function(Player)
	local StatsValue = {}
	
	for _, v in pairs(game.ReplicatedStorage.Stats:GetChildren()) do
		print(v.HasGot.Value)
		StatsValue['Material'] = v.Name
		StatsValue['HowMuch'] = v.Value
		StatsValue['Unlocked'] = v.HasGot.Value
	end
end)

If the problem related to HasGot further continues, please comment and lemme know. If you want realtime help, you can ask for my discord DM.

3 comments

0

My script is different, he dosen't work like that because there is multiple Stats so there is a lot of table inside of the same table, wich is then saved inside Datastores with JSONEncode.

0

Well, if you try to print the contents of the table, it will be in encoded form and it cannot be decoded. That is why, I suggested you this method. You can only use table.insert in arrays.

0

Yes, but I don't think its the problem, because even if I print it again without adding it in a table or anything like that, it still diseapear like printing it would delete it

This discussion is preserved as it was. New answers, comments, and votes are closed.