Help with a shop script

local stuffs ={
	b1 ={
		cost = 1.5,
		amt = 10,
		name = "Handful of Seeds",
		desc = "Miniscule amount of seeds"
	} ,
	b2 ={
		cost = 3,
		amt1 = 25,
		name = "Pocketful of Seeds",
		desc = "Small amount of seeds"
	} ,
	b3 ={
		cost = 6,
		amt2 = 60,
		name = "Pouch of Seeds",		
		desc = "Some seeds"
	} ,
	b4 ={
		cost = 10,
		amt3 = 80,
		name = "Sack of Seeds",
		desc = "Alot of seeds"
	} ,
	b5 ={
		cost = 40,
		amt4 = 125,
		name = "Crate of Seeds",
		desc = "An unneeded amount of seeds"
	} ,
	b6 ={
		cost = 75,
		amt5 = 200,
		name = "Vault of Seeds",
		desc = "An insane, obscene amount of seeds. There is no need for this many seeds."
	}
}
script.Parent.b1.MouseButton1Click:Connect(function(hit)
	local var = stuffs.b1
	local cost = var.cost
	local amt = 0
    amt = var.amt
	local name = var.name
	local desc = var.desc
	local dmg = 1
	script.Parent.holder.img.cost.Text = cost.." Cash"
	script.Parent.holder.img.desc.Text = desc
	script.Parent.holder.img.iname.Text = name
 
	script.Parent.holder.img.amount.Text = amt
	script.Parent.holder.img.buybutton.MouseButton1Click:Connect(function(hit)
		if script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value > (cost-1) then
			script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value -= cost
			if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") or script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
				if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds").Amount.Value += amt
				elseif script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds").Amount.Value += amt
				end
			else
				local clo = game.ServerStorage.Seeds:Clone()
				clo.Parent = script.Parent.Parent.Parent.Parent.Backpack
				clo.Amount.Value += amt
			end
			game.SoundService["Windows Tada Sound"]:Play()
		end
	end)
end)
script.Parent.b2.MouseButton1Click:Connect(function(hit)
	local var = stuffs.b2
	local cost = var.cost
	local amt = 0
    amt = var.amt1
	local name = var.name
	local desc = var.desc
	local dmg = 1
	script.Parent.holder.img.cost.Text = cost.." Cash"
	script.Parent.holder.img.desc.Text = desc
	script.Parent.holder.img.iname.Text = name
 
	script.Parent.holder.img.amount.Text = amt
	script.Parent.holder.img.buybutton.MouseButton1Click:Connect(function(hit)
		if script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value > (cost-1) then
			script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value -= cost
			if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") or script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
				if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds").Amount.Value += amt
				elseif script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds").Amount.Value += amt
				end
			else
				local clo = game.ServerStorage.Seeds:Clone()
				clo.Parent = script.Parent.Parent.Parent.Parent.Backpack
				clo.Amount.Value += amt
			end
			game.SoundService["Windows Tada Sound"]:Play()
		end
	end)
end)
script.Parent.b3.MouseButton1Click:Connect(function(hit)
	local var = stuffs.b3
	local cost = 60
	local amt = 0
	amt = var.amt2
	local name = var.name
	local desc = var.desc
	local dmg = 1
	script.Parent.holder.img.cost.Text = cost.." Cash"
	script.Parent.holder.img.desc.Text = desc
	script.Parent.holder.img.iname.Text = name
 
	script.Parent.holder.img.amount.Text = amt
	script.Parent.holder.img.buybutton.MouseButton1Click:Connect(function(hit)
		if script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value > (cost-1) then
			script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value -= cost
			if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") or script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
				if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds").Amount.Value += amt
				elseif script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds").Amount.Value += amt
				end
			else
				local clo = game.ServerStorage.Seeds:Clone()
				clo.Parent = script.Parent.Parent.Parent.Parent.Backpack
				clo.Amount.Value += amt
			end
			game.SoundService["Windows Tada Sound"]:Play()
		end
	end)
end)
script.Parent.b4.MouseButton1Click:Connect(function(hit)
	local var = stuffs.b4
	local cost = var.cost
	local amt = 0
	amt = var.amt3
	local name = var.name
	local desc = var.desc
	local dmg = 1
	script.Parent.holder.img.cost.Text = cost.." Cash"
	script.Parent.holder.img.desc.Text = desc
	script.Parent.holder.img.iname.Text = name
 
	script.Parent.holder.img.amount.Text = amt
	script.Parent.holder.img.buybutton.MouseButton1Click:Connect(function(hit)
		if script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value > (cost-1) then
			script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value -= cost
			if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") or script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
				if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds").Amount.Value += amt
				elseif script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds").Amount.Value += amt
				end
			else
				local clo = game.ServerStorage.Seeds:Clone()
				clo.Parent = script.Parent.Parent.Parent.Parent.Backpack
				clo.Amount.Value += amt
			end
			game.SoundService["Windows Tada Sound"]:Play()
		end
	end)
end)
script.Parent.b5.MouseButton1Click:Connect(function(hit)
	local var = stuffs.b5
	local cost = var.cost
	local amt = 0
	amt = var.amt4
	local name = var.name
	local desc = var.desc
	local dmg = 1
	script.Parent.holder.img.cost.Text = cost.." Cash"
	script.Parent.holder.img.desc.Text = desc
	script.Parent.holder.img.iname.Text = name
 
	script.Parent.holder.img.amount.Text = amt
	script.Parent.holder.img.buybutton.MouseButton1Click:Connect(function(hit)
		if script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value > (cost-1) then
			script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value -= cost
			if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") or script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
				if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds").Amount.Value += amt
				elseif script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds").Amount.Value += amt
				end
			else
				local clo = game.ServerStorage.Seeds:Clone()
				clo.Parent = script.Parent.Parent.Parent.Parent.Backpack
				clo.Amount.Value += amt
			end
			game.SoundService["Windows Tada Sound"]:Play()
		end
	end)
end)
script.Parent.b6.MouseButton1Click:Connect(function(hit)
	local var = stuffs.b6
	local cost = var.cost
	local amt = 0
	amt = var.amt5
	local name = var.name
	local desc = var.desc
	local dmg = 1
	script.Parent.holder.img.cost.Text = cost.." Cash"
	script.Parent.holder.img.desc.Text = desc
	script.Parent.holder.img.iname.Text = name
 
	script.Parent.holder.img.amount.Text = amt
	script.Parent.holder.img.buybutton.MouseButton1Click:Connect(function(hit)
		if script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value > (cost-1) then
			script.Parent.Parent.Parent.Parent.leaderstats.Cash.Value -= cost
			if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") or script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
				if script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Backpack:FindFirstChild("Seeds").Amount.Value += amt
				elseif script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds") then
					script.Parent.Parent.Parent.Parent.Character:FindFirstChild("Seeds").Amount.Value += amt
				end
			else
				local clo = game.ServerStorage.Seeds:Clone()
				clo.Parent = script.Parent.Parent.Parent.Parent.Backpack
				clo.Amount.Value += amt
			end
			game.SoundService["Windows Tada Sound"]:Play()
		end
	end)
end)

Im trying to make the script show an info card on the seeds, and then you are able to buy the seeds. It works, but when you buy different amounts it gives you the other amounts you have bought previously. For example, you buy 10 seeds. You get 10. Then you decide to buy 25 seeds, but you get 35. I’ve encountered this issue before with devproducts, but I fixed them, and forgot how to since it was so long ago. Any thoughts?

figured out the issue, dont exactly know how to resolve it. when you click on the item, the info card pops up, but if you click on it alot it decides to (for lack of a better term) open it alot. so when you go to buy, you are buying the open ones

Fixed it. No need to reply anymore.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.