My Data Store Isn't Saving At All And I Am Not Sure Why I Need Some Help
Here Is My Script
CashStore = game:GetService("DataStoreService"):GetDataStore("RPCash")
local plr = game.Players.PlayerAdded
local Money = script.Parent.Cash
function PlayerEntered(player)
repeat wait() until player.Character
local Money = script.Parent.Cash
if CashStore:GetAsync("RPCash_"..player.Name) ~= nil then
Money.Value = CashStore:GetAsync("RPCash_"..player.Name)
else
Money.Value = 500
end
Money.Changed:connect(function(Val)
CashStore:SetAsync("RPCash_"..plr.Name, Val)
end)
end
game.Players.PlayerAdded:connect(PlayerEntered)
game.Players.PlayerRemoving:Connect(function(plr)
local Val = Money.Value
local success, errormessage = pcall(function()
CashStore:SetAsync("RPCash_"..plr.Name, Val)
end)
if success then
wait()
else
print(errormessage)
CashStore:SetAsync("RPCash_"..plr.Name, Val)
end
end)

1 comment
This is not the answer to your question, but you should never save data when the value changes. That is an easy way to hit the data store limits. And you are not even implementing data stores correctly.