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

I have a saving money script but it doesn't work, what is the problem here?

Asked by 6 years ago
Edited 6 years ago

i have this script

01local currencyName = "Point"
02local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore")
03game.Players.PlayerAdded:Connect(function(player)
04 
05    local folder = Instance.new("Folder")
06    folder.Name = "leaderstats"
07    folder.Parent = player 
08 
09    local currency = Instance.new("IntValue")
10    currency.Name = currencyName
11    currency.Parent = folder
12    currency.Value = 0
13local ID = currencyName.."-"..player.UserId
14    local savedData = nil  
15 
View all 50 lines...

shop script

01local price = script.Parent.Parent.Price
02local tools = game:GetService("ReplicatedStorage"):WaitForChild("Tools")
03local tool = tools:FindFirstChild(script.Parent.Parent.ItemName.Value)
04local player = script.Parent.Parent.Parent.Parent.Parent.Parent
05 
06script.Parent.MouseButton1Click:Connect(function()
07    if player.leaderstats:WaitForChild("Point") then
08        if player.leaderstats.Point.Value >= price.Value then
09             player.leaderstats.Point.Value =  player.leaderstats.Point.Value - price.Value
10            local clone = tool:Clone()
11            clone.Parent = player.Backpack
12 
13            local clone2 = tool:Clone()
14            clone2.Parent = player.StarterGear
15        end
16    end
17end)

Actually, it works. When you play, if you buy the Points from the gamepass, the points is still be saved. But when you use that points to buy things in shop, the script doesn't save the points which have been decrease. Can anyone solve the problem? Thanks you guys a lot

0
You don't give the script of the shop? How are we supposed to find a solution then? However, the problem may be that you're changing the value of points on the client, so the server doesn't recognize it. Are you using RemoteEvents to decrease the points? User#22980 0 — 6y
0
ok iamthepurpleguy10 15 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I Have This DS From My Old Game Here You Go

BTW DO YOU HAVE API SERVICES ON?

01local currencyname = "Gems"
02local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStoreNameHere")
03local RS = game:GetService("ReplicatedStorage")
04game.Players.PlayerAdded:Connect(function(player)
05 
06    local folder = Instance.new("Folder")
07    folder.Name = "leaderstats"
08    folder.Parent = player
09 
10    local currency = Instance.new("IntValue")
11    currency.Name = currencyname
12    currency.Parent = folder
13 
14 
15    local SavedData = nil
View all 51 lines...
0
yes, i have. iamthepurpleguy10 15 — 6y
Ad

Answer this question