I am trying to modify an invisible leaderstats with a local script and it works, but it doesn't. When I leave and join the game my money is the same and I do not have the thing I have purchased.
Local script (shop item)
local item = script.Parent local rs = game.ReplicatedStorage local Noob = script.Parent.Parent.Parent.Frame3.Equip.Noob local value = 10 -- Change this to the price of your item 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 - value item.Text = "Purchased" Noob.Visible = true value = 0 game.Players.LocalPlayer.leaderstats1.Purchases3.Value = 4 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)
Local script (get value (inventory))
local purchases = game.Players.LocalPlayer.leaderstats1.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)
Data Store (Invisble Leaderstats)
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)
Thanks!