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

saving inventory not saving ?

suppose to save everything in the inventory, and leaderboard stats.. it doesnt save anything..

function load(player)
	if player.DataReady then 
		if player then
			wait()
			local score = player.Folder:GetChildren()
			for i = 1,#score do
				
					local ScoreLoaded = player:LoadNumber(score[i].Name)
					wait()
					if ScoreLoaded ~= 0 then
						score[i].Value = ScoreLoaded
					else

					end
				end
			
			----Load Inventory----
			local inventory = player:findFirstChild("Inventory")
			if inventory then
				local saved_inv = player:LoadInstance("Invent")
				if saved_inv then
					for j,k in pairs(saved_inv:GetChildren()) do
						k.Parent = inventory
					end
				end
			end
			end
	end
	end
function onPlayerEntered(player)
	local Inventory = Instance.new("Folder")
	Inventory.Name = "Inventory"
	Inventory.Parent = player

	local leaderboard = Instance.new("Folder")
	leaderboard.Name = "Folder"
	leaderboard.Parent = player
	
	local Beli = Instance.new("IntValue")
	Beli.Value = 10
	Beli.Name = "Beli"
	Beli.Parent = leaderboard

	local Trys = Instance.new("IntValue")
	Trys.Value = 2
	Trys.Name = "Trys"
	Trys.Parent = leaderboard

	local DF = Instance.new("StringValue")
	DF.Name = "DF"
	DF.Parent = leaderboard

	local GotDF = Instance.new("IntValue")
	GotDF.Value = 0
	GotDF.Name = "GotDF"
	GotDF.Parent = leaderboard

	local SetDF = Instance.new("IntValue")
	SetDF.Value = 0
	SetDF.Name = "SetDF"
	SetDF.Parent = leaderboard

	local Scene = Instance.new("IntValue")
	Scene.Value = 1
	Scene.Name = "Scene"
	Scene.Parent = leaderboard



	player:WaitForDataReady()
	load(player)
	wait()
end

function onPlayerLeaving(player)
end

game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)

1 comment

0

I dont think that DataReady is a property of "Player"

1 answer

✓ Accepted answer

Try using this line in localscript:

game.Players.LocalPlayer:SaveNumber(string Key, number Value)

Or to load:

game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer:LoadNumber(string Key)

1 comment

0

"Server-side only Data persistance methods cannot be called from within a LocalScript. You'll need to process the saving in a Script." http://wiki.roblox.com/index.php?title=Data_persistence#Restrictions

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