Below is the script for a dailog shop. It is very similar to that found in roblox wiki here.
local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player, choice)
local stats = player:FindFirstChild('leaderstats')
if not stats then return end
local gold = stats:FindFirstChild('Gold')
if not gold then return end
if choice == script.Parent.DialogChoice.ChoiceA then
if gold.Value >= 500 then
game.ReplicatedStorage.AK-47:Clone().Parent = player.Backpack
gold.Value = gold.Value - 500
end
While this script works, I want to make it so if you buy the AK, it replaces a certain weapon in your backpack (example, if you have a healthkit and a assault rifle in your backpack, buying the AK replaces the assault rifle ONLY).
Thanks!

1 comment
Your wording throws me off a bit. Try making an example script?