I don’t understand why it keeps giving me this error code, I couldn’t find anything wrong myself.
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local krons = Instance.new("IntValue")
krons.Name = "Krons"
krons.Parent = leaderstats
local data
local success, errormessage = pcall(function()
data = experienceStore:GetAsync(player.UserId.."currency")
end)
if success then
krons.Value = data
else
print("Error while data load")
warn(errormessage)
end
end)
game.Players.PlayerAdded:Connect(function(player)
local success, errormessage = pcall(function()
experienceStore:SetAsync(player.UserId.."-Krons",player.leaderstats.Krons.Value)
end)
if success then
print("Player Data Saved")
else
print("Failed Save")
warn(errormessage)
end
end)