local DSService = game:GetService('DataStoreService'):GetDataStore('namehere')
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
for i,v in pairs(charbio:GetChildren()) do
v.Value = GetSaved[i]
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)
print("saved")
end)
game.OnClose = function()
wait(30)
end
It always prints "saved" when players exit, but it never saves changes made to their data throughout their time playing.

6 comments
how do you know it isnt saving?
OnClose is deprecated, I believe it wasn't even working properly, and you could only have one function bound. With :BindToClose you can bind multiple functions. Use :BindToClose instead.
you didnt show us where you're doing anything with the datastore besides saving so its impossible for anyone to know what else could be wrong.
use game:BindToClose instead of game.OnClose
you didnt even setasync or anything
They did use :SetAsync(), but what throws me off is the fact the DataStore name is "namehere". What your problem might be is that you're using values to update data, but if the values themselves have no value, then you're not updating anything really. Check if your values are even updating. You never even set values to your stringvalues.