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

Why wont my Datastore save anything?

It does not show that any errors have occurred, but when I exit and then re-enter my game, all data is lost.

local DSService = game:GetService('DataStoreService'):GetDataStore('Testing')
game.Players.PlayerAdded:connect(function(plr)
	
	local uniquekey = 'id'..plr.userId
	
	local charbio = Instance.new('Folder',plr)
	charbio.Name = "CharacterBio"
	
	local new = Instance.new('StringValue',charbio)
	new.Name = "New"
	
	local gender = Instance.new('StringValue',charbio)
	gender.Name = "Gender"
	
	local hair = Instance.new('StringValue',charbio)
	hair.Name = "Hair"
	
	local hairc = Instance.new('StringValue',charbio)
	hairc.Name = "HairC"
	
	local shirt = Instance.new('IntValue',charbio)
	shirt.Name = "Shirt"
	
	local pants = Instance.new('IntValue',charbio)
	pants.Name = "Pants"
	
	local dress = Instance.new('StringValue',charbio)
	dress.Name = "Dress"
	
	local mask = Instance.new('StringValue',charbio)
	mask.Name = "Mask"
	
	local gloves = Instance.new('IntValue',charbio)
	gloves.Name = "Gloves"
	
	local elite = Instance.new('StringValue',charbio)
	elite.Name = "Elite"
	
	local class = Instance.new('StringValue',charbio)
	class.Name = "Class"
	
	local scar = Instance.new('IntValue',charbio)
	scar.Name = "Scar"
	
	local skin = Instance.new('StringValue',charbio)
	skin.Name = "Skin"
	
	local gold = Instance.new('IntValue',charbio)
	gold.Name = "Gold"
	
	local level = Instance.new('IntValue',charbio)
	level.Name = "Level"
	
	local exp = Instance.new('IntValue',charbio)
	exp.Name = "Experience"
	
	local GetSaved = DSService:GetAsync(uniquekey)
	if GetSaved then
		
	local t = {new.Value,gender.Value,hair.Value,hairc.Value,shirt.Value,pants.Value,dress.Value,mask.Value,gloves.Value,elite.Value,class.Value,scar.Value,skin.Value,gold.Value,level.Value,exp.Value}
	for i,v in pairs(t) do
	t = GetSaved
	end
		
	else
		
		local NumbersForSaving = {new.Value,gender.Value,hair.Value,hairc.Value,shirt.Value,pants.Value,dress.Value,mask.Value,gloves.Value,elite.Value,class.Value,scar.Value,skin.Value,gold.Value,level.Value,exp.Value}
		DSService:SetAsync(uniquekey,NumbersForSaving)
		
	end
	
end)

game.Players.PlayerRemoving:connect(function(plr)
	
	local uniquekey = 'id'..plr.userId
	local bio = plr.CharacterBio
	local Savetable = {bio.New.Value,bio.Gender.Value,bio.Hair.Value,bio.HairC.Value,bio.Shirt.Value,bio.Pants.Value,bio.Dress.Value,bio.Mask.Value,bio.Gloves.Value,bio.Elite.Value,bio.Class.Value,bio.Scar.Value,bio.Skin.Value,bio.Gold.Value,bio.Level.Value,bio.Experience.Value} 
	DSService:SetAsync(uniquekey,Savetable)
	
end)


1 answer

✓ Accepted answer

You can't set an Objects Value if you save it to a table or a variable. You have to save the Object itself.

	if GetSaved then
		for i,v in pairs(charbio:GetChildren()) do
			v.Value = GetSaved[i]
		end
	end
--What to do
local obj = Instance.new("IntValue")
obj.Value = 100
--What not to do
local obj = Instance.new("IntValue").Value
obj = 100

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