i get no error message or script errors?
local datastoreservice = game:GetService("DataStoreService")
local mydata = datastoreservice:GetDataStore("mydata")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local HatPoints = Instance.new("IntValue", leaderstats)
HatPoints.Name = "HatPoints"
local Credits = Instance.new("IntValue", leaderstats)
Credits.Name = "Credits"
local PlayerUserid = "Player_"..player.UserId
local success, errormessage = pcall(function()
data = mydata:GetaSync(PlayerUserid)
end)
if success then
Credits.Value = data
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local PlayerUserid = "Player_"..player.UserId
local data = player.leaderstats.Credits.Value
local success, errormessage = pcall(function()
mydata:SetAsync(PlayerUserid, data)
end)
if success then
print("Good")
else
print("Bad")
warn(errormessage)
end
end)
