Guys I have a question. I'm making a "Bank Sistem" where you can store money and be safe from being stealed from other players! For now I've made a "Deposit" button where when you click it it creates a "Owner" value (StringValue) and inside that a "Money" value (NumberValue). It stores the money how it is supposed to but, When a player leaves I want these values to be saved and to delete themselfes when the player leaves to give space to other players money values.
Here's the script:
script.Parent.MouseButton1Click:connect(function()
local playermoney = game.Players.LocalPlayer.leaderstats.Money.Value
local deposit = script.Parent.Deposit
local owner = Instance.new("StringValue",deposit)
owner.Name = "Owner"
owner.Value = game.Players.LocalPlayer.Name
wait(1)
local depositmoney = Instance.new("NumberValue",deposit.Owner)
depositmoney.Name = "Money"
depositmoney.Value = playermoney
end)
game.Players.PlayerRemoving:connect(function()
if not game.Players:FindFirstChild(owner.Value) then
--Save script here I suppose? 0.o
deposit.Owner:Destroy() --Destroy the files.
end
end)
Any idea how I do that? I'll read every comment/answer.

2 comments
A couple problems with this. First off PlayerLeft is not a thing, it's PlayerRemoving. Secondly, You are trying to Datastore a value from the client side, which you can't do. Finally, if your game is FE then you can't change the leaderstats value from the client and expect it to replicate. I suggest reading on RemoteEvents before continuing.
Well that doesn't help -.-