hi guys!!! today i got a little problem with my datasore
i dont know why but when i put my datastore script the value is always equal to 20 idk why
here is the script
====== datastore une valeur
game.Players.PlayerAdded:Connect(function(player)
local plruserid = player.UserId
local saving = datakey:GetAsync(plruserid)
local leaderstats =Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "cash"
cash.Parent = leaderstats
local data
local success, errormessage = pcall(function()
data = datakey:GetAsync(plruserid)
if data then
cash.Value = data
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local plruser = player.UserId
local data = player.leaderstats.cash.value
local success,errormessage = pcall(function()
datakey:SetAsync(plruser,data)
if datakey then
print("succefully save")
else
print("got an error")
end
end)
end)
```pls help me i dont really undesrtand why the value always equal to 20 but Enjoy!!!