local DSService = game:GetService('DataStoreService'):GetDataStore('DBSRClosedTestv9')
game.Players.PlayerAdded:connect(function(p)
wait(game.Lighting.TimeToLoad.Value)
-- Define variables
local stats = game.ServerStorage.PlayerData:Clone()
stats.Parent = p
stats.Level.Value = 1
stats.StrengthValue.Value = 0
stats.speedValue.Value = 1
stats.maxKi.Value = 100
stats.MaxStaminaValue.Value = 100
stats.kiDamage.Value = 0
stats.kiControl.Value = 0
stats.kiValue.Value = 100
stats.AgilityValue.Value = 0
stats.PowerLevel.Value = 100
stats.currentHealth.Value = 100
stats.defenseValue.Value = 0
stats.attributePoints.Value = 0
stats.exp.Value = 0
stats.Zeni.Value = 0
stats.Hair.Value = 0
stats.BodyHeight.Value = 1
stats.BodyWidth.Value = 1
print("Done")
--stats.mouth.Value = 1
stats.Face.Value = 1
local uniquekey = 'id-'..p.userId
local names = {}
for i, v in pairs(p.PlayerData:GetChildren()) do
table.insert(names, v.Name)
end
-- GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
for i, v in pairs(p.PlayerData:GetChildren()) do
v.Value = GetSaved[i]
end
for i=1, #GetSaved do
print(i .. ": " .. names[i] .. " = " .. tostring(GetSaved[i]))
end
else
local NumbersForSaving = {}
for i, v in pairs(p.PlayerData:GetChildren()) do
table.insert(NumbersForSaving, v.Value)
end
DSService:SetAsync(uniquekey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(p)
local uniquekey = 'id-'..p.userId
local Savetable = {}
for i, v in pairs(p.PlayerData:GetChildren()) do
table.insert(Savetable, v.Value)
end
DSService:SetAsync(uniquekey, Savetable)
end)
COMMUNITY QUESTION
How would I make this be able to save Color3 values as well?
1 answer
You can create a Color3Value and just save the Value
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
it pops up an error when I do so