local DataStore = game:GetService("DataStoreService")
local grandopeningkitsds = DataStore:GetDataStore("GrandOpeningKits")
game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new("Folder",player)
stats.Name = "stats" -- creates a leaderboard
local statsloaded = Instance.new("BoolValue")
statsloaded.Parent = player.stats
statsloaded.Name = "StatsLoaded"
-- CREATES GRAND-OPENING-KITS VALUE --
local grandopeningkits = Instance.new("NumberValue")
grandopeningkits.Parent = player.stats
grandopeningkits.Name = "GrandOpeningKits" -- creates a leaderstat value
grandopeningkits.Value = grandopeningkitsds:GetAsync(player.UserId) or 0 -- gets past value
grandopeningkitsds:SetAsync(player.UserId,grandopeningkits.Value) -- sets a new value
local grandopeningkitnum = grandopeningkits.Value
-- SETS STATSLOADED VALUE TO TRUE --
statsloaded.Value = true
-- LEAVE BACKUP SAVE --
game.Players.PlayerRemoving:connect(function(player)
print("Saving Data for user "..player.UserId)
grandopeningkitsds:SetAsync(player.UserId,player.stats.GrandOpeningKits.Value)
print(player.UserId.."'s Data has been saved successfully.")
if error then
print("DATA ERROR: "..player.UserId.."'s Data has been saved unsuccessfully")
end
end)
end)
I use a similar script on another game and it works fine. Anybody know whats going on?

2 comments
If you're just going off of "if error then" It should save. You never defined error so "error" is always the error function. Otherwise can you post an error? Or is there no errors.
Perhaps you need to save the value rather than the Value Object. (i.e, line 27 add a .Value to the end of GrandOpeningKit)