So I'm getting an error saying
19:48:28.816 - ServerScriptService.Leaderboard:51: bad argument #3 to 'Value' (string expected, got boolean)
19:48:28.817 - Script 'ServerScriptService.Leaderboard', Line 51
19:48:28.817 - Stack End
The value's I'm trying to save are IntValue's and StringValue's
**Here's my script : **
-- ayy lmao local DSService = game:GetService("DataStoreService"):GetDataStore("PlayerSaveData") game.Players.PlayerAdded:connect(function(plr) local uniquekey = "id-"..plr.userId local m = Instance.new("Model", plr) m.Name = "leaderstats" local i = Instance.new("IntValue", m) i.Name = "Cash" local w = Instance.new("IntValue", m) w.Name = "Wins" local inb = Instance.new("BoolValue", plr) inb.Name = "InBattle" inb.Value = false local GB = Instance.new("BoolValue", plr) GB.Name = "GroupBonus" GB.Value = false local ID = Instance.new("BoolValue", plr) ID.Name = "IsDueling" ID.Value = true local Skin = Instance.new("StringValue", plr) Skin.Name = "CurrentSkin" Skin.Value = "ClassicSword" local MissingLink = Instance.new("StringValue", plr) MissingLink.Name = "MissingLink" MissingLink.Value = "false" if plr:IsInGroup(2852908) then if GB.Value == false then plr:WaitForChild('leaderstats'):WaitForChild('Cash').Value = plr:WaitForChild('leaderstats'):WaitForChild('Cash').Value + 500 GB.Value = true else end end local GetSaved = DSService:GetAsync(uniquekey) if GetSaved then i.Value = GetSaved[1] w.Value = GetSaved[2] GB.Value = GetSaved[3] Skin.Value = GetSaved[4] MissingLink.Value = GetSaved[5] else local NumbersForSaving = {i.Value, w.Value, GB.Value, ID.Value, Skin.Value, MissingLink.Value} DSService:SetAsync(uniquekey, NumbersForSaving) end end) game.Players.PlayerRemoving:connect(function(plr) local uniquekey = "id-"..plr.userId local Savetable = {plr.leaderstats.Cash.Value, plr.leaderstats.Wins.Value, plr['GroupBonus'].Value, plr['IsDueling'].Value, plr['MissingLink'].Value, plr['CurrentSkin'].Value} DSService:SetAsync(uniquekey, Savetable) end)
At the bottom, in your SetAsync
, you have plr['IsDueling'].Value
being fed into the spot in the tuple (fancy name for inflexible table) being fed into the 4th spot, and in line 51, the Skin is being accessed from the 4th spot. I think this was simply a miswrite of the SetAsync
, since you later save CurrentSkin
into the 6th spot on the tuple.
To fix this, move CurrentSkin
to the 4th spot in the tuple, and delete IsDueling
from it. I'm not sure why you would need to save that anyway, since none of the variables you load seem to care about IsDueling
.