Okay so I have made the script to be able to buy the weapons, but I can't figure out how to make it sell the weapons as well, in case a player makes the wrong purchase.
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 >= 20 then game.Lighting.Brown:Clone().Parent = player.Backpack Gold.Value = Gold.Value - 20 end elseif choice == dialog.DialogChoice.ChoiceB then if Gold.Value >= 40 then game.Lighting.Arion:Clone().Parent = player.Backpack Gold.Value = Gold.Value - 40 end elseif choice == dialog.DialogChoice.ChoiceC then if Gold.Value >= 1000 then game.Lighting.Trail:Clone().Parent = player.Backpack Gold.Value = Gold.Value - 1000 end elseif choice == dialog.DialogChoice.ChoiceD then if Gold.Value >= 2000 then game.Lighting.Overlord:Clone().Parent = player.Backpack Gold.Value = Gold.Value - 2000 end end end)
Thanks if you read this and double thanks if you reply
Simply reverse it; but there is a problem. You need experience with guis to be able to do this. You need to make a gui that lists all of the chosen items. Here is what you do to sell, though:
local tax = 5 -- percentage, remove if you don't want. local button = script.Parent local item = game.Players.LocalPlayer.Backpack:FIndFirstChild(button.ItemName.Value) local cost = item.Cost local stats = game.Players.LocalPlayer:FindFirstChild("leaderstats") local g = stats:FindFirstChild("Gold") button.MouseButton1Down:connect(function() if g and item then g = g + cost.Value item:remove() end end)
Note: I made this to be used in a gui.
Hope I helped :)