My Datastore doesn’t seem to save any data, I don’t see any problem or error with the Datastore
``
local players = game:GetService(“Players”)
local datastore = game:GetService(“DataStoreService”)
local ds1 = datastore:GetDataStore(“LightQuality”)
local ds2 = datastore:GetDataStore(“CareerKills”)
local ds3 = datastore:GetDataStore(“NameOfWeapon”)
local ds4 = datastore:GetDataStore(“NameOfWeaponGUI”)
local ds7 = datastore:GetDataStore(“FieldOfView”)
local ds8 = datastore:GetDataStore(“AT1”)
local ds9 = datastore:GetDataStore(“AT2”)
local ds10 = datastore:GetDataStore(“AT3”)
local ds11 = datastore:GetDataStore(“AT4”)
local ds12 = datastore:GetDataStore(“AT4”)
local ds13 = datastore:GetDataStore(“AT6”)
local EFFE = datastore:GetDataStore(“EffectsAreEnabled”)
local CareerPoints = datastore:GetDataStore(“EXP”)
local HeadshotKills = datastore:GetDataStore(“HeadShots”)
local LongshotKills = datastore:GetDataStore(“LongShots”)
local PointBlankKills = datastore:GetDataStore(“PointBlanks”)
local HipFireKills = datastore:GetDataStore(“HipFires”)
local DoubleKillCount = datastore:GetDataStore(“DoubleKills”)
local PlayerLevel = datastore:GetDataStore(“Lvl”)
local CrouchingKills = datastore:GetDataStore(“CrouchKills”)
local ProningKills = datastore:GetDataStore(“ProneKills”)
local MotionBlur = datastore:GetDataStore(“MotionBlurSave”)
–// Ignore the event fires.
players.PlayerAdded:connect(function(player)
local folder = Instance.new("IntValue")
folder.Name = "leaderstats"
folder.Parent = player
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "1")
local QL = Instance.new("BoolValue")
QL.Name = "QualityLight"
QL.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "2")
QL.Value = ds1:GetAsync(player.UserId) or true
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "3")
local CKills = Instance.new("IntValue")
CKills.Name = "CareerKills"
CKills.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "4")
CKills.Value = ds2:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "5")
local Points = Instance.new("NumberValue")
Points.Name = "Points"
Points.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "6")
local CPoints = Instance.new("IntValue")
CPoints.Name = "CareerPoints"
CPoints.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "7")
CPoints.Value = CareerPoints:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "8")
local OpenGun = Instance.new("StringValue")
OpenGun.Name = "OpenGun"
OpenGun.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "9")
OpenGun.Value = ds3:GetAsync(player.UserId) or "A1_M16"
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "10")
local GunID = Instance.new("StringValue")
GunID.Name = "GunID"
GunID.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "11")
GunID.Value = ds4:GetAsync(player.UserId) or "M16"
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "12")
local EE = Instance.new("BoolValue")
EE.Name = "EffectsEnabled"
EE.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "13")
EE.Value = EFFE:GetAsync(player.UserId) or true
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "14")
local At1 = Instance.new("IntValue")
At1.Name = "AT1"
At1.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "15")
At1.Value = ds8:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "16")
local At2 = Instance.new("IntValue")
At2.Name = "AT2"
At2.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "17")
At2.Value = ds9:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "18")
local At3 = Instance.new("IntValue")
At3.Name = "AT3"
At3.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "19")
At3.Value = ds10:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "20")
local At4 = Instance.new("IntValue")
At4.Name = "AT4"
At4.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "21")
At4.Value = ds11:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "22")
local At5 = Instance.new("IntValue")
At5.Name = "AT5"
At5.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "23")
At5.Value = ds12:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "24")
local At6 = Instance.new("IntValue")
At6.Name = "AT6"
At6.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "25")
At6.Value = ds13:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "26")
local FOV = Instance.new("IntValue")
FOV.Name = "FOV"
FOV.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "27")
FOV.Value = ds7:GetAsync(player.UserId) or 70
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "28")
local HeadShots = Instance.new("IntValue")
HeadShots.Name = "HeadshotKills"
HeadShots.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "29")
HeadShots.Value = HeadshotKills:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "30")
local LongShots = Instance.new("IntValue")
LongShots.Name = "LongshotKills"
LongShots.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "31")
LongShots.Value = LongshotKills:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "32")
local PointBlanks = Instance.new("IntValue")
PointBlanks.Name = "PointblankKills"
PointBlanks.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "33")
PointBlanks.Value = PointBlankKills:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "34")
local HipFires = Instance.new("IntValue")
HipFires.Name = "HipfireKills"
HipFires.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "35")
HipFires.Value = HipFireKills:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "36")
local DBK = Instance.new("IntValue")
DBK.Name = "DoubleKills"
DBK.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "37")
DBK.Value = DoubleKillCount:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "38")
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Parent = player.leaderstats
Kills.Value = 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "39")
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "40")
Level.Value = PlayerLevel:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "41")
local CrouchingKs = Instance.new("IntValue")
CrouchingKs.Name = "CrouchingKills"
CrouchingKs.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "42")
CrouchingKs.Value = CrouchingKills:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "43")
local ProningKs = Instance.new("IntValue")
ProningKs.Name = "ProningKills"
ProningKs.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "42")
ProningKs.Value = ProningKills:GetAsync(player.UserId) or 0
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "43")
local MB = Instance.new("BoolValue")
MB.Name = "MotionBlur"
MB.Parent = player.leaderstats
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "45")
MB.Value = MotionBlur:GetAsync(player.UserId) or false
game.ReplicatedStorage.ClientFinished:FireClient(player, no, "45")
print("firing in 3 seconds")
wait(3)
game.ReplicatedStorage.ClientFinished:FireClient(player, done)
CPoints.Changed:Connect(function()
local x = Level.Value
if CPoints.Value >= math.floor( (7500 * ((x) ^0.33)) ) then
print(“levelup”)
CPoints.Value = CPoints.Value - math.floor((7500*((x)^0.33)))
Level.Value = Level.Value + 1
game.ReplicatedStorage.Levelup:FireClient(player, Level.Value)
end
end)
Level.Changed:Connect(function()
PlayerLevel:SetAsync(player.UserId, Level.Value)
end)
end)
players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
Save(“QualityLight”, ds1, player)
Save(“CareerKills”, ds2, player)
Save(“CareerPoints”, CareerPoints, player)
Save(“OpenGun”, ds3, player)
Save(“GunID”, ds4, player)
Save(“EffectsEnabled”, EFFE, player)
Save(“AT1”, ds8, player)
Save(“AT2”, ds9, player)
Save(“AT3”, ds10, player)
Save(“AT4”, ds11, player)
Save(“AT5”, ds12, player)
Save(“AT6”, ds13, player)
Save(“FOV”, ds7, player)
Save(“HeadshotKills”, HeadshotKills, player)
Save(“LongshotKills”, LongshotKills, player)
Save(“PointblankKills”, PointBlankKills, player)
Save(“HipfireKills”, HipFireKills, player)
Save(“DoubleKills”, DoubleKillCount, player)
Save(“CrouchingKills”, CrouchingKills, player)
Save(“ProningKills”, ProningKills, player)
Save(“Level”, PlayerLevel, player)
Save(“MotionBlur”, MotionBlur, player)
end)
if success then
print(“DataSaved”)
else
print(“error”)
warn(errormessage)
end
end)
function Save(Leaderstat, Saveplace, Plr)
Saveplace:SetAsync(Plr.UserId, (Plr.leaderstats:FindFirstChild(Leaderstat).Value))
end
``
I think that the player is leaving before the data is saved, support is appreciated.