I want to save players' money but any scripts I find do not work
To save a players' leaderstats (aka "money" in your case) you should research about DataStore.
Method 1: Basic
When Player Enters,
If they have data stored already,
Get the data,
If they don't have any data,
Create a new data file,
Replace the data file with a default value,
When Player Leaves,
Overall, if you're trying to save a player's stats without having to research all of this stuff, use this code:
--[ Variables ]-- local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("7D7FD5D49A1AD4B650017503FBDF93C5") --[ Player Enter: Load Data ]-- game.Players.PlayerAdded:Connect(function(player) --[ Create Leaderstats ]-- local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local Cash = Instance.new("IntValue",leader) Cash.Name = "Money" --[ Load Values ]-- Cash.Value = ds:GetAsync(player.UserId) or 0 --[ Prevent Data Loss: 1 ]-- ds:SetAsync(player.UserId, Cash.Value) --[ Prevent Data Loss: 2 ]-- Cash.Changed:connect(function() ds:SetAsync(player.UserId, Cash.Value) end) end) --[ Player Leave: Save Data ]-- game.Players.PlayerRemoving:Connect(function(player) --[ Save Data ]-- ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) end)
I was able to remove the deprecated code so that you won't get called out for.
Closed as Not Constructive by valchip, green271, Vulkarin, and User#19524
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?