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

Why does the following code output nothing and not save the data?

game.Players.PlayerRemoving:Connect(function(player)
player.CharacterRemoving:Connect(function(character)
	for i, v in pairs(character:GetChildren()) do
		if v:IsA("BoolValue") then
			if game.ReplicatedStorage:FindFirstChild(v.Name) then
					
				local UserId = "Player_"..player.UserId..v.Name
			
				local data = {
					Money = player.Money.Value;
					Kunai = player.Kunai.Value;
				}
					local success, errormessage = pcall(function()
						GameData:SetAsync(UserId, data)
				end)
				if success then
					print("Data Saved Succesfully")
				else
					print("Data Did Not Save Correctly")
					warn(errormessage)
				end
				
			end
			
		end
		end
	end)
end)

2 comments

0

what if you delete "warn(errormessage)" ?

0

or delete end at line 25 cuz i don't see anything wrong with the datastore part of this script. and i don't think you can warn a pcall :v

2 answers

Try making data into a dictionary rather than an array. I don't think you can save arrays.

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