My Question is relevant to this code:
local DSService = game:GetService('DataStoreService'):GetDataStore('JerryYoutube-Spells-Place-5')
-- Name of Data Store Must be random, long or obscure to make sure that it is not taken as an ID for another Store of Data
game.Players.PlayerAdded:connect(function(plr)
local loaded = script.Parent.loaded
loaded.Value = 0
-- Def Vars
local IdPlr = "id-"..plr.userId
local ls = Instance.new("IntValue", plr)
-- Ls = LeaderStats
local ls2 = Instance.new("IntValue",plr)
local sv = Instance.new("IntValue")
-- Save Value
ls.Name = 'ls'
-- if u change ^ u must change them all
ls2.Name = 'ls2'
sv.Parent = ls
sv.Name = 'Spell_Count'
-- U can change ^ if u want - but u must change all the other references as well
local sv2 = Instance.new("IntValue")
sv2.Parent = ls2
sv2.Name = "Rank"
-- Get Async
local RVFS = DSService:GetAsync(IdPlr)
-- Return Values From Saved (Data)
if RVFS then
sv.Value = RVFS[1]
sv2.Value = RVFS[1]
else
local NFS = {sv.Value}
local NFS2 = {sv2.Value}
-- Numbers for Saving (Int-Type) operand + , num(spells)
DSService:SetAsync(IdPlr,NFS)
DSService:SetAsync(IdPlr,NFS2)
end
loaded.Value = 1
Admin_Check(plr)
end)
game.Players.PlayerRemoving:connect(function(plr)
local IdPlr = "id-"..plr.userId
-- Since it has the identifier "Local" it cannot be referenced in between functions; because of OOP
local ST = {plr.ls.Spell_Count.Value}
local ST2 = {plr.ls2.Rank.Value}
DSService:SetAsync(IdPlr,ST)
DSService:SetAsync(IdPlr,ST2)
end)
function Admin_Check(plr)
-- Function Deals with the connection of Clients to the Server and helps the main function check if the User is an Admin
-- Takes an Input of player
-- GSP : Get Spell count of Player
print(game.Workspace.Scripts.Storage.IdLoader.loaded.Value)
local DSService = game:GetService('DataStoreService'):GetDataStore('JerryYoutube-Spells-Place-5')
local GSP = game.StarterGui.GSP
local Rank = game.StarterGui.RankControl
GSP.Enabled = false -- Changes the GetSpellCount of Player Screen Gui to not show
if game.Workspace.Scripts.Storage.IdLoader.loaded.Value == 1 then
print("Loaded TRUE")
end
if plr.UserId == 92471106 then
print("Owner JerryYoutube is Online!")
print(plr.ls.Spell_Count.Value)
print(plr.ls2.Rank.Value)
GSP.Enabled = true -- Changes the GetSpellCount of Player Screen Gui to show
Rank.Enabled = true
elseif plr.UserId == 63044886 then
print("Admin tjminecraft1 is Online!")
GSP.Enabled = true
Rank.Enabled = true
else
GSP.Enabled = false
Rank.Enabled = false
end
GetRank(plr,plr.ls2.Rank.Value)
end
function GetRank(plr,rank)
print(rank)
print(plr)
end
And I would like to know why the values for both no longer save in-game. As I tested this code with Just 1 leaderstats and 1 value in that leaderstats (ls and sv) and It worked. i would Like to know why it doesn't work and please can someone patch it up so that I can store 2 values in the one leaderstats table and save both when the player (plr) leaves. And loads their data (plr) when they return.
Thanks for any help you can give.

6 comments
Your data store does not get shared with other places (like Jailbreak or anything). As long as you dont repeat the same data store name in YOUR (like the code you write, not in other games) code, you should be fine.
Also, please consistently rather instance value objects with the parent object (dont do this with BaseParts), or set the parent after. Not both, your code gets messy.
Also, read my answer on here https://scriptinghelpers.org/questions/48045/why-doesnt-my-forward-declaration-of-a-function-work
@hiimgoodpack - unfortunately - I tried what u said but its not working - oculd u pls further clarify
Its called suggestions, not an answer.
erm - why can I not save 2 Int-Values in LeaderStats?