Why is my DataStore script not working?
local GDS = game:GetService("DataStoreService")
local cash_1 = GDS:GetDataStore("Cash_1")
game.Players.PlayerAdded:Connect(function (player)
leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
cash = Instance.new("IntValue", leaderstats)
cash.Name = "Cash" --Change this to the name of what needs to be on the leaderboard
playerSaveID = "Player_"..player.UserId
print(playerSaveID.." has joined!")
local success, errormessage = pcall(function()
end)
local data = cash_1:GetAsync(playerSaveID)
if success then
data = cash.Value
print(playerSaveID.."'s save restored!")
end
end)
game.Players.PlayerRemoving:Connect(function()
local data = cash.Value
local success, errormessage = pcall(function()
cash_1:SetAsync(playerSaveID,data)
end)
if success then
print(playerSaveID.."'s data saved!")
end
end)```