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

Data store table issues?

I'm trying to make this Data Store save a player's backpack, and load it when they come back, but nothing happens, nothing returns with printing, no errors in the output. (Ignore the Kills part, it works fine)

if player_store:GetAsync("Kills") then
	Kills.Value = player_store:GetAsync("Kills")
	else
	Kills.Value = 0
	end
	if player_store:GetAsync("Weapons") then
	for i,v in pairs (player.BackPack:GetChildren()) do
		v:remove()
	end
	local Weapons = player_store:GetAsync("Weapons")
	for i in Weapons do
		game.Lighting:FindFirstChild(i):Clone().Parent = player.BackPack
	end
	end
end)

game.Players.PlayerRemoving:connect(function(player)
	player_store = DataStore:GetDataStore(player.userId.."Z")
	if player_store:GetAsync("Kills") then
	player_store:SetAsync("Kills", player.leaderstats.Kills.Value)
	else
	player_store:SetAsync("Kills", player.leaderstats.Kills.Value)	
	end
	if player_store:GetAsync("Weapons") then
		print 'its here'
	local Weapons = {}
	for i,v in pairs (player.BackPack:GetChildren()) do
		Weapons[v] = v
	end
	player_store:SetAsync("Weapons", Weapons)
	else
	local Weapons = {}
	for i,v in pairs (player.BackPack:GetChildren()) do
		Weapons[v] = v
	end
	player_store:SetAsync("Weapons", Weapons)
	end
end)

game.Close:connect(function() wait (5) end)

2 comments

0

I remember helping you with something like this a week or so ago :{

0

Well now im trying to table within it, what you helped me with works

1 answer

✓ Accepted answer

You could simplify a lot of the code you've posted. I remember helping you with something like this here, refer to that for further information.

Question: how are you verifying that these saved stats are specific to players? What you have presented would update the data store Kills with the last player's Kill statistic, and your scripts would be based on that last player's stat, but will affect all players...

In other words, if one player works hard to achieve a high kill stat, player after him will ruin that achievement because their stat will basically replace his.

1 comment

0

I just realized the script error had nothing to do with scripting. The weapon set that is saved is my old weapons and then the ones its trying to load are the new ones, which all have completely different names

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