I'm making a Shop script that has GUI's and everything. It works, but it gives me 6 of the items instead of 1. Can anyone help?
aduritecost = 500
americancost = 1000
--banhammer = admin
canadiancost = 1000
cupcakecost = 100
diecost = 100
dogecost = 250
galaxycost = 800
goldencost = 5000
koolcost = 400
mediccost = 500
missingtexturecost = 1800
moneycost = 10000
nightvisioncost = 500
noobcost = 50
robloxcost = 500
rainbowcost = 2500
unicorncost = 10000
tediorecost = 7500
ukcost = 1000
yeetcost = 15000
local player = game.Players.LocalPlayer
local shopgui = player.PlayerGui:WaitForChild("ShopGUI")
local shopmaster = shopgui:WaitForChild("ShopMaster")
local pages = shopmaster:WaitForChild("Pages")
local knives = pages:WaitForChild("Knives")
local description = knives:WaitForChild("Description")
local purchasesound = knives:WaitForChild("PurchaseNoise")
local replicatedstorage = game:GetService("ReplicatedStorage")
local knifestorage = replicatedstorage:WaitForChild("KnifeStorage")
local knifename = description:WaitForChild("ItemName")
local buy = description:WaitForChild("BuyButton")
--when preferred item is shown
--checks if player chose item
--clicks on the buy
--buys it
--done
function checkandbuy()
buy.MouseButton1Click:connect(function()
if knifename.Text == ("Adurite Knife") then
local leaderstats = player:FindFirstChild("leaderstats")
local coins = leaderstats:FindFirstChild("Coins")
if coins.Value >= aduritecost then
coins.Value = coins.Value - aduritecost
knifestorage.AduriteKnife:clone().Parent = player.Backpack
wait(2)
end
elseif knifename.Text == ("American Knife") then
local leaderstats = player:FindFirstChild("leaderstats")
local coins = leaderstats:FindFirstChild("Coins")
if coins.Value >= americancost then
coins.Value = coins.Value - americancost
knifestorage.AmericanKnife:clone().Parent = player.Backpack
wait(2)
end
elseif knifename.Text == ("Ban Hammer") then
if player.Name == "Zingoro" or "Jxemes" or "LinkMe" or "GoodCreeper917" then
wait(1)
knifestorage.BanHammer:clone().Parent = player.Backpack
wait(2)
end
else
end
end)
end
knifename.Changed:connect(checkandbuy)
buy.Changed:connect(checkandbuy)

8 comments
Got 2 things. What is the difference between MouseButton1Down and MouseButton1Click? And it doesn't work. It still gives me 6.
For first thing, not much of a difference. Second, add prints to find out where it gives more
Still doesn't work, I added prints and there is no source of telling where the cloning is! I think I should restart.
Here, i think you should change that function(), remove it and maybe make it buy.MouseButton1Click:connect(function() in that add all those other weapon things..
NVM, I fixed it using Black's way. Thanks tho neil.
Hurray :D
Hurray :D
Hurray :D