I'm making a shop and it works fine just when I leave and enter the game, I have the same amount of money before I bought the item and the item is not in my inventory?
Scripts:
Data Store
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("Purchases1SaveSystem") local ds2 = datastore:GetDataStore("Purchases2SaveSystem") local ds3 = datastore:GetDataStore("PurchasesSaveSystem") local ds4 = datastore:GetDataStore("Purchases3SaveSystem") game.Players.PlayerAdded:connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "leaderstats1" local purchases1 = Instance.new("IntValue", folder) purchases1.Name = "Purchases1" local purchases2 = Instance.new("IntValue", folder) purchases2.Name = "Purchases2" local purchases = Instance.new("IntValue", folder) purchases.Name = "Purchases" local purchases3 = Instance.new("IntValue", folder) purchases3.Name = "Purchases3" purchases1.Value = ds1:GetAsync(plr.UserId) or 0 ds1:SetAsync(plr.UserId, purchases1.Value) purchases2.Value = ds2:GetAsync(plr.UserId) or 0 ds2:SetAsync(plr.UserId, purchases2.Value) purchases3.Value = ds4:GetAsync(plr.UserId) or 0 ds4:SetAsync(plr.UserId, purchases3.Value) purchases.Value = ds3:GetAsync(plr.UserId) or 0 ds3:SetAsync(plr.UserId, purchases.Value) purchases1.Changed:connect(function() ds1:SetAsync(plr.UserId, purchases1.Value) end) purchases3.Changed:connect(function() ds4:SetAsync(plr.UserId, purchases3.Value) end) purchases2.Changed:connect(function() ds2:SetAsync(plr.UserId, purchases2.Value) end) purchases.Changed:connect(function() ds3:SetAsync(plr.UserId, purchases.Value) end) end)
Shop (Item)
local item = script.Parent local rs = game.ReplicatedStorage local Noob = script.Parent.Parent.Parent.Frame3.Equip.Noob local value = 10 item.MouseButton1Click:connect(function() if game.Players.LocalPlayer.leaderstats.Money.Value >= value then game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - 0 item.Text = "Purchased" Noob.Visible = true value = 0 script.Parent.Parent.Parent.Frame3.Locked.Noob1.Visible = false script.Parent.Parent.Parent.Available.Visible = true wait(2) script.Parent.Parent.Parent.Available.Visible = false else item.Text = "Purchase Failed" wait(1) item.Text = "Noob $10" if game.Players.LocalPlayer.leaderstats1.Purchases3.Value == 4 then value = 0 Noob.Visible = true end end end)
Inventory Data Store Recognition
local purchases = game:WaitForChild("Players").LocalPlayer:WaitForChild("leaderstats1"):WaitForChild("Purchases3") purchases.Changed:Connect(function() if purchases.Value == 4 then print("NoobT") script.Parent.Visible = true script.Parent.Parent.Parent.Locked.Noob1.Visible = false else print("Bye") script.Parent.Visible = false end end)
I have been trying to fix this for weeks and am still learning LUA, I'd really appreciate it if you could help! Thanks!