PlayerCash.Cash, based on your definitions is player.leaderstats.Cash.Cash
That aside, I think the issue is whatever/wherever “CashGiver” is. I have doubts it is stored inside the event “MouseClick.” I’m guessing that is actually the parent?
I’d just drop “CashGiver” and see if that fixes it.
It didn’t unfortunately but here is the cash script
local DataStorageService = game:GetService(“DataStoreService”)
local myDataStore = DataStorageService: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 playerUserId = "Player_"..player.UserId
--Load Data
local data
local succes, errormessage = pcall(function()
data = myDataStore:GetAsync(playerUserId)
end)
if succes then
Cash.Value = data
--Setdata to the current cash
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = “Player_”…player.UserId
local data = player.leaderstats.Cash.Value
local success, errormessage = pcall(function()
myDataStore:SetAsync(playerUserId, data)
end)
if success then
print("Data successfully saved!")
else
print("error im gonna cry")
warn(errormessage)
end
I am a self taught scripter so I don’t really know why I just know how I can use it. My guess would be that = is the current value and when you add a plus it’s number plus the current value. Don’t quote me on it tho.
The += is shorthand for “increment” which then adds the other value to the current value. It was added as shorthand by programmers who got tired of typing the longer version.