https://cdn.discordapp.com/attachments/447457287376994304/494905176889753610/unknown.png this is the folders
this is the script for the shop
button = game.StarterGui.Shop.Frame.ImageButton
player = game.Players.LocalPlayer
cost = game.ReplicatedStorage.StatFile.LocalPlayer.statnumbers.cost1.Value
add = 1
button.MouseButton1Down:connect(function()
if player.leaderstats.Money.Value >= cost then
player.leaderstats.Money.Value = player.leaderstats.Money.Value - cost
player.leaderstats.MPS.Value = player.leaderstats.MPS.Value + add
cost = cost + 50
end
end)
while true do
wait(0.01)
script.Parent.Text = "Cost: "..cost
end
also i want it to save the cost the intvalue but im not sure if i have done the datastore correctly
local DS = game:GetService("DataStoreService"):GetDataStore("test")
local StatFile = game:GetService("ReplicatedStorage"):WaitForChild("StatFile")
game.Players.PlayerAdded:connect(function(player)
local playerFolder = Instance.new("Folder", StatFile)
playerFolder.Name = player.Name
local statnumbers = Instance.new("Folder", playerFolder)
statnumbers.Name = "statnumbers"
local cost1 = Instance.new("IntValue", statnumbers)
cost1.Name = "cost1"
local add1 = Instance.new("IntValue", statnumbers)
add1.Name = "add1"
local thing = Instance.new("StringValue", statnumbers)
thing.Name = "thing"
local str = Instance.new("StringValue", statnumbers)
str.Name = 'str'
str.Value = 'thisIsAString'
local savedStuff = DS:GetAsync(player.userId)
if savedStuff then
print('data takes up '..game:GetService("HttpService"):JSONEncode(savedStuff):len()..'/260000')
for i,v in pairs(savedStuff)do
print(i,v)
if i % 2 == 0 then
StatFile[player.Name].statnumbers:FindFirstChild(savedStuff[i - 1]).Value = v
end
end
end
end)
local function saveValues(player)
local savedData = {}
for i,v in pairs(StatFile[player.Name].statnumbers:GetChildren()) do
savedData[#savedData + 1] = v.Name
savedData[#savedData + 1] = v.Value
end
DS:SetAsync(player.userId, savedData)
end
game:BlindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
saveValues(player)
end
end)
game.Players.PlayerRemoving:connect(function(player)
saveValues(player)
end)

3 comments
do i put that in the shop item or the datastore?
script on Workspace (it on my game so insert int values on Buttons for buying can name them ammount and then fix the path) it works fine on me
i dont really understand cause im quite new to scripting is there anyway you could try fix it its very confusing to me