When I click play the message 'err' loads up , what is causing this?
local DataStoreService = game:GetService("DataStoreService")
local http = game:GetService("HttpService")
local PlayerData = DataStoreService:GetDataStore("PlayerData")
game.Players.PlayerAdded:Connect(function(player)
local Leaderstats = Instance.new("Folder",player)
Leaderstats.Name = "Leaderstats"
local Shards = Instance.new("IntValue",Leaderstats)
Shards.Name = "Shards"
local Level = Instance.new("IntValue",Leaderstats)
Level.Name = "Level"
local data
local suc, err = pcall(function()
data = http:JSONDecode(PlayerData:GetAsync(player.UserId))
end)
if suc then
if data then
player.Leaderstats.Shards.Value = data.Shards
player.Leaderstats.Level.Value = data.Level
player:LoadCharacterWithHumanoidDescription(data.humDescription) -- load it with the description
else
player.Leaderstats.Shards.Value = 0 -- ur default value
player.Leaderstats.Level.Value = 0 -- same here
end
else
warn('err')
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local data = {
Shards = player.Leaderstats.Shards.Value,
Level = player.Leaderstats.Level.Value,
humDescription = game.Players:GetHumanoidDescriptionFromUserId(player.UserId) -- save the description
}
PlayerData:SetAsync(http:JSONEncode(data))
end)

6 comments
probably the warn('err')............... duh
well obv , its there to tell me something went wrong right? @greatneil80
try print (err), the variable value
sayingggg Argument 1 missing or nil @greatneil80 @InedibleGames
Basically, the datastore didn't load correctly, so suc (short for success) was false. The code was warn('err'), replace with warn(err)
Saying Arg 1 missing or nil when loading in and Arg 2 missing or nil when exiting @TTChaos