local DataStoreService = game:GetService("DataStoreService")
local MyDataStore = DataStoreService:GetDataStore("DataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Cash = Instance.new("NumberValue",leaderstats)
Cash.Name = "Cash"
local Stand = Instance.new("StringValue",leaderstats)
Stand.Name = "Stand"
local data
local Success,Errormessage = pcall(function()
data = MyDataStore:GetAsync(player.UserId.."-Cash",player.UserId.."-Stand")
end)
if Success then
Cash.Value = data
else
print("Error Getting Ur 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)
MyDataStore:SetAsync(player.UserId.."-Stand",player.leaderstats.Stand.Value)
end)
if Success then
print("Players Data Was Saved")
else
print("There was a error loading the data")
warn(error)
end
end)
COMMUNITY QUESTION
Datastore not saving i dont know the issue?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Explain more about the error