Ok, I was the first person to join the game and now I'm the only person with a value in the leaderboard, the issue is when another person joins it errors saying "Argument Missing or nil" on line 12 of the following script and I have no idea why. Anyone know why?
DataStore = game:GetService("DataStoreService"):GetDataStore("Values")
game.Players.PlayerAdded:connect(function(plr)
local val = 0
local save = "plr-"..plr.userId
local savedVals = DataStore:GetAsync(save)
if savedVals then
val = savedVals
else
val = 0
DataStore:SetAsync(save)
end
local stat = Instance.new("IntValue", plr)
stat.Name = "leaderstats"
local cred = Instance.new("IntValue", stat)
cred.Value = val
cred.Name = "Credits"
end)
game.Players.PlayerRemoving:connect(function(plr)
local val = plr.leaderstats.Credits.Value
local save = "plr-"..plr.userId
DataStore:SetAsync(save)
end)

1 comment
Thank you so much!