Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make it so the cash saves? Please help! [closed]

Asked by
piRadians 297 Moderation Voter
7 years ago

This question already has an answer here:

How to use DataStores?

Hi, I made it so every 60 seconds or 1 minute, you get 50 cash, but It doesn't save, how do I use datastorage? pls help, thanks.

01function onPlayerEntered(newPlayer)
02 
03    local stats = Instance.new("IntValue")
04    stats.Name = "leaderstats"
05 
06    local cash = Instance.new("IntValue")
07    cash.Name = "Cash"
08    cash.Value = 100
09 
10    cash.Parent = stats
11    stats.Parent = newPlayer
12    while true do
13        cash.Value = cash.Value + 50
14        wait(60)
15    end
16end
17 
18 
19 
20game.Players.ChildAdded:connect(onPlayerEntered)

Marked as Duplicate by Shawnyg

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago

This is a pretty simple script I made for my game. In my game, I made it so it saves the minutes (currency) of the player on the leaderboard. Here's the script

01function onPlayerEntered(player)
02wait()-- Change to wait for player longer.
03player:WaitForDataReady()
04repeat wait() until player:FindFirstChild("leaderstats")
05if player.DataReady then
06if player:findFirstChild("leaderstats") then
07local score = player.leaderstats:GetChildren()
08for i = 1,#score do
09local ScoreLoaded = player:LoadNumber(score[i].Name)
10wait()
11if ScoreLoaded ~= 0 then
12score[i].Value = ScoreLoaded
13end
14end
15end
View all 29 lines...
0
Enjoy! ReallyAdvanced -2 — 7y
0
P.S Just leave this in workspace. ReallyAdvanced -2 — 7y
0
This will not work, I don't even see the DataStore service greatneil80 2647 — 7y
0
You're using deprecated terms in this script. 'SaveNumber' is associated with Data Persistence, which has long been deprecated. DataStore is the new way to save data. Shawnyg 4330 — 7y
Ad