I am trying to store values in a table and save and load them, but they aren't saving, I am calling the module from a script in serverscriptservice, and I have api services enabled, and there are no errors, if anyone can help that'd be great
Code:
local data = {}
local datastore = game:GetService("DataStoreService"):GetDataStore("RPG 1")
function data.load(plr)
local key = plr.UserId
local stats = Instance.new("Folder", plr)
stats.Name = "Stats"
local level = Instance.new("NumberValue", stats)
level.Name = "Level"
level.Value = 1
local currentExp = Instance.new("NumberValue", stats)
currentExp.Name = "CurrentExp"
currentExp.Value = 0
local maxExp = Instance.new("NumberValue", stats)
maxExp.Name = "MaxExp"
maxExp.Value = 250
local gold = Instance.new("NumberValue", stats)
gold.Name = "Gold"
gold.Value = 100
local values = {level.Value, currentExp.Value, maxExp.Value, gold.Value}
local savedValues = datastore:GetAsync(key, values)
if savedValues ~= nil then
values = savedValues
end
end
function data.save(plr)
local key = plr.UserId
local values = {plr.Stats.Level.Value, plr.Stats.CurrentExp.Value, plr.Stats.MaxExp.Value, plr.Stats.Gold.Value}
datastore:SetAsync(key, values)
end
return data

2 comments
Errors?
There are no errors