Why is it setting bought to false

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

iam trying to make a shop system, when you buy it you can’t buy it again

  1. What is the issue? Include screenshots / videos if possible!

so i set it to true so i can’t buy it again but its sets to false instead idk why

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

i looked everywhere

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local Shop = {
	[1] = {Cost = 1000, Name = "Copper", bought = false};
	[2] = {Cost = 10000, Name = "Charged Copper", bought = false}
}

local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer

local Info = Player.PlayerGui.Ui.Shop.Info
local BuyProp = nil

function Shop.ShowInfo(Button, Name, Cost)
	print(Button)
	Button.Image.MouseButton1Click:Connect(function()
		Info.name.Text =  Name
		Info.Price.Text =  Cost
		Info.Visible = true
		BuyProp = Name
	end)
end

function Shop.Load()
	for i = 1, #Shop do
		local Curr = Shop[i];
		local Name, Price = Curr.Name, Curr.Cost;

		local NewFrm  = RS.FrmObject:Clone()
		NewFrm.Name = Name
		NewFrm.Parent = Player.PlayerGui:WaitForChild("Ui").Shop.ScrollingFrame
		NewFrm.name.Text = Name
		NewFrm.Cost.Text = Price

		Shop.ShowInfo(NewFrm, Name, Price)
		--NewFrm.Image.Image
		
	end
end

Info.Buy.MouseButton1Click:Connect(function()
	if BuyProp ~= nil then
		for i = 1, #Shop do
			local Curr = Shop[i];
			local Name, Bought, Cost = Curr.Name, Curr.bought, Curr.Cost;
			print(Bought)
			if Cost <= Player.leaderstats.MegaCoins.Value then
				if Name == BuyProp then
					if Bought == false then
						print(Bought)
						print("bought".. BuyProp)
						Bought = true
						print(Bought)
						RS.BuyRank:FireServer(BuyProp, Cost)
					end
				end
			end
		end
	end
end)

return Shop

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

If this script is being called/required multiple times. It will always start with false since that is what you set in the table.

If you want to truly store weather a user bought X item or not. Go with datastores.

can you tell me where to start becuase iam not really a expert at datastore