Alright so I have a script that will basically allow some of my NPC's to hand out items if a certain dialogue option is picked. What I need help is for the fact that items will cost Knockouts, not Gold. Script was taken from the ROBLOX Wiki under the NPC dialogue shop tutorial. How do I change the script so it tells the NPC to sell weapons based on KO's not Gold?
local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player, choice)
-- Check the player has a stats object
local stats = player:FindFirstChild('leaderstats')
if not stats then return end
-- And that the stats object contains a gold member
local gold = stats:FindFirstChild('Gold')
if not gold then return end
if choice == script.Parent.DialogChoice.ChoiceA then
if gold.Value >= 5 then -- 5 is the amount of gold you need to purchase this weapon
game.ReplicatedStorage.Weapon1:Clone().Parent = player.Backpack
gold.Value = gold.Value - 5 -- subtract the amount of gold you need to purchase
end
elseif choice == dialog.DialogChoice.ChoiceB then
if gold.Value >= 10 then
game.ReplicatedStorage.Weapon2:Clone().Parent = player.Backpack
gold.Value = gold.Value - 10
end
elseif choice == dialog.DialogChoice.ChoiceC then
if gold.Value >= 15 then
game.ReplicatedStorage.Weapon3:Clone().Parent = player.Backpack
gold.Value = gold.Value - 15
end
end
end)

2 comments
Just change line 8 into "local gold = stats:FindFirstChild('KOs')" since gold is just a variable it doesn't matter if you change it or not.
Zephy, you there are 2 answers, you can look at 2 of them. I wrote the 2nd one because alpha didn't explain it well. I also added some things that might help you in later games!