i think im using the data store wrong
local DSService = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(plr)
local Ukey = "id-"..plr.UserId
local leaderstat = Instance.new("IntValue",plr)
leaderstat.Name = "leaderstats"
local LevelValue = Instance.new("IntValue",leaderstat)
LevelValue.Parent = leaderstat
LevelValue.Name = "Level"
local Sp = Instance.new("StringValue",leaderstat)
Sp.Parent = leaderstat
Sp.Name = "Power"
Sp.Value = ""
local GetSaved = DSService:GetAsync(Ukey)
if GetSaved then
LevelValue.Value = GetSaved[1]
Sp.Value = GetSaved[2]
else
local NumbersForSaving = {LevelValue.Value,Sp.Value}
DSService:SetAsync(Ukey,NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local Ukey = "id-"..plr.UserId
local Savetable = {plr.leaderstats.Level.Value,plr.leaderstats.Sp.Value}
DSService:SetAsync(Ukey,Savetable)
end)

1 comment
sorry but this didnt help and it didnt even store the values in the datastore or didnt retrieve it and eitherway it still says that line 15 has a error