Whenever I click "yes" to purchase the sword, it charges me twice and it gives me 2 swords. I'm not sure why it does this, but I also get blue underline where it says "yesConnect:disconnect", on line 28.
price = 10
plr = game.Players.LocalPlayer
isowned = false
script.Parent.MouseButton1Down:connect(function()
local KOs = plr.leaderstats:WaitForChild("KOs")
if KOs.Value > price and isowned == false then
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.AreYouSure.Visible = true
local yesConnect
yesConnect = script.Parent.Parent.Parent.AreYouSure.Yes.MouseButton1Down:connect(function()
isowned = true
KOs.Value = KOs.Value - price
local sworda = game.ReplicatedStorage.NoobSword:Clone()
sworda.Parent = plr.Backpack
local swordb = game.ReplicatedStorage.NoobSword:Clone()
swordb.Parent = plr.StarterGear
script.Parent.Parent.Visible = true
script.Parent.Parent.Parent.AreYouSure.Visible = false
end)
elseif isowned == true then
print('already owned')
end
local noConnect
noConnect = script.Parent.Parent.Parent.AreYouSure.No.MouseButton1Down:connect(function()
script.Parent.Parent.Visible = true
script.Parent.Parent.Parent.AreYouSure.Visible = false
yesConnect:disconnect()
noConnect:disconnect()
end)
end)

4 comments
I had it that way because I need it my backpack and in startergear so you keep it on respawn.
It still charges twice, and I don't get the sword after buying now.
ok I will edit
there we go!