hello developers hope you are well…
I have a problem with my datastore because when I leave of game it automatically saves what I had but if I buy something and I have less money left it doesn’t save
local datastore = game:GetService("DataStoreService")
local Miranura = datastore:GetDataStore("MiRanura")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Strength = Instance.new("IntValue",leaderstats)
Strength.Name = "ZDFS"
--datastore
local identificacion = player.UserId
Strength.Value = Miranura:GetAsync(identificacion)
end)
game.Players.PlayerRemoving:Connect(function(player)
local identificacion = player.UserId
Miranura:SetAsync(identificacion, player.leaderstats.ZDFS.Value)
end)
if someone can help me thank you very much
by the way if you wonder how to add money: add money from the command bar
I already checked if I had an error but apparently not. I explain better:
if I enter my game which is missing a lot: ZDF [ zona de fuego ] - Roblox
and I write in the command console that I add it to the leaderstats it adds it and saves it but if for some reason I go to the restaurant I buy something it remains but it does not save if someone can solve it please I beg you
THAKCS…
local playerID = player.UserId
local data = Miranura:GetAsync(playerID)
if data then
Strength.Value = data[1]
else
Strength.Value = [dafault_Value]
end
Change the default_Value to the default value of strength if the player first join the game.
Paste this codes below the note you wrote: “–datastore”