So I'm making a datastore script, it's located in server script service and it's a regular script. I made the script and it worked fine until I added all of the car bool values. The goal of the script is to save money xp rank and then a bunch of bool value's that are the cars people have bought. once I added the car bools everything stopped saving. I tried some trouble shooting but nothing seems to work. I'm not very experienced in datastores.
Also the event that fires when it loads the player data is suppose to put the car models of the cars that the player has purchased in owned cars and that event script works fine, the only issue is the values ether won't save or load.
Heres the script:
local DataStore = game:GetService("DataStoreService"):GetDataStore("RedLineRacing-DS")
local EventTutorial = game:GetService("ReplicatedStorage").TutorialEvent
local EventRank = game:GetService("ReplicatedStorage").RankUpLocal
local EventCarLoaded = game:GetService("ReplicatedStorage").PlayerLoadedCarsLocal
game.Players.PlayerAdded:Connect(function(player)
local key = "Player-ID:"..player.userId
local CarStorage = Instance.new("Folder", player)
CarStorage.Name = "OwnedCars"
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Money = Instance.new("NumberValue",leaderstats)
Money.Name = "Rowg Coins"
Money.Value = 15000
local MiDriven = Instance.new("NumberValue",leaderstats)
MiDriven.Name = "Miles Driven"
MiDriven.Value = 0
local Rank = Instance.new("StringValue",leaderstats)
Rank.Name = "Rank"
Rank.Value = "Permit"
local Ae86Value = Instance.new("BoolValue", leaderstats)
Ae86Value.Name = "Ae86"
local A180Value = Instance.new("BoolValue", leaderstats)
A180Value.Name = "A180"
local A1968ChallengerValue = Instance.new("BoolValue", leaderstats)
A1968ChallengerValue.Name = "A1968Challenger"
local A911Value = Instance.new("BoolValue", leaderstats)
A911Value.Name = "A911"
local AccordValue = Instance.new("BoolValue", leaderstats)
AccordValue.Name = "Accord"
local CamaroValue = Instance.new("BoolValue", leaderstats)
CamaroValue.Name = "Camaro"
local CorvetteValue = Instance.new("BoolValue", leaderstats)
CorvetteValue.Name = "Corvette"
local HuracanValue = Instance.new("BoolValue", leaderstats)
HuracanValue.Name = "Huracan"
local LFAValue = Instance.new("BoolValue", leaderstats)
LFAValue.Name = "LFA"
local LanEvoValue = Instance.new("BoolValue", leaderstats)
LanEvoValue.Name = "LanEvo"
local MiataValue = Instance.new("BoolValue", leaderstats)
MiataValue.Name = "Miata"
local ModelSValue = Instance.new("BoolValue", leaderstats)
ModelSValue.Name = "ModelS"
local SennaValue = Instance.new("BoolValue", leaderstats)
SennaValue.Name = "Senna"
local SupraValue = Instance.new("BoolValue", leaderstats)
SupraValue.Name = "Supra"
local GetSave = DataStore:GetAsync(key)
if GetSave then
Money.Value = GetSave[1]
MiDriven.Value = GetSave[2]
Rank.Value = GetSave[3]
Ae86Value.Value = GetSave[4]
A180Value.Value = GetSave[5]
A1968ChallengerValue.Value = GetSave[6]
A911Value.Value = GetSave[7]
AccordValue.Value = GetSave[8]
CamaroValue.Value = GetSave[9]
CorvetteValue.Value = GetSave[10]
HuracanValue.Value = GetSave[11]
LFAValue.Value = GetSave[12]
LanEvoValue.Value = GetSave[13]
MiataValue.Value = GetSave[14]
ModelSValue.Value = GetSave[15]
SennaValue.Value = GetSave[16]
SupraValue.Value = GetSave[17]
EventCarLoaded:FireAllClients()
print('tried to fire events')
print("Data loaded for"..player.Name)
else
EventTutorial:FireAllClients()
local Numbers = {Money.Value, MiDriven.Value, Rank.Value, Ae86Value.Value, A180Value.Value, A1968ChallengerValue.Value, A911Value.Value, AccordValue.Value, CamaroValue.Value, CorvetteValue.Value, HuracanValue.Value, LFAValue.Value, LanEvoValue.Value, MiataValue.Value, ModelSValue.Value, SennaValue.Value, SupraValue.Value}
DataStore:SetAsync(key, Numbers)
print("Data Saved for"..player.Name)
end
MiDriven.Changed:Connect(function()
EventRank:FireAllClients()
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local key = "Player-ID:"..player.userId
local ValuesToSave = {player.leaderstats["Rowg Coins"].Value, player.leaderstats["Miles Driven"].Value, player.leaderstats.Rank.Value, player.leaderstats.Ae86.Value, player.leaderstats.A180.Value, player.leaderstats.A1968Challenger.Value, player.leaderstats.A911.Value, player.leaderstats.Accord.Value, player.leaderstats.Camaro.Value, player.leaderstats.Corvette.Value, player.leaderstats.Huracan.Value, player.leaderstats.LFA.Value, player.leaderstats.LanEvo.Value, player.leaderstats.Miata.Value, player.leaderstats.ModelS.Value, player.leaderstats.Senna.Value, player.leaderstats.Supra.Value}
DataStore:SetAsync(key, ValuesToSave)
end)
Does anyone know a solution?

4 comments
I broke my scroll wheel for this.
the spaces..
Yeah scripting helpers now makes you write questions with stack edit, and I have never used stack edit before lol.
The actual script is only 135 lines of code.