Hey, Sorry for using urgent but I need your help. My game is practisly done but I didn't do one thing: Data store. So I read some articles about and see some videos about. I have to store three IntValue: Win/Money/Medicine.
So, I see the AlvinBlox tutorial and I copy exactly the same script ( I have allowed the data in game settings :D ) and the script didn't save the cash (Studio and game) and I need to know why ?
Here is the script
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
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 = myDataStore:GetAsync(player.UserId.."-cash") or 0
print("Data load")
end)
if success then
cash.Value = data
else
print("Error while loading data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-cash",player.leaderstats.Cash.Value)
end)
if success then
print("Data saved")
else
print("Error while saving data")
warn(errormessage)
end
end)
The print("Data saved") work one in a half. If you have some tips for doing that, thanks a lot ! So really thanks for answer to this topic ! :D

3 comments
Have you tried using BindToClose or using my datastore method located in the forum?
why are you even using his tutorials, theyre garbage lol
What is BindToClose exaclty ?