I see this posted alot in the discord. Since there is not a built in way to sell, I made a script a long time ago that works well for selling. I've refined it over time to include stacks of items as well. I've attached a barebones project with everything you need (script and widget included) to allow your players to sell to a merchant.
Project attached and script below:
//check if an item is in the inventory slot for selling
if widget["Sell_Widget"].element["0001"].item != null then
//store item cost, name and count of the item in the sell slot
$Item1Cost = widget["Sell_Widget"].element["0001"].item.cost;
$Item1Name = widget["Sell_Widget"].element["0001"].item.name;
$Item1Count = widget["Sell_Widget"].element["0001"].item.count;
//divide the set cost of the item by 2, you can change this to reduce it's value however you want, if at all
$Item1Value = $Item1Cost / 2;
//multiply the cost by the item count
$Item1Value = $Item1Count * $Item1Value;
//round the value to remove decimals
$Item1ValueRounded = round($Item1Value);
//display the item count, name and rounded value and prompt player to confirm the sale
$sell = display_choices("Would you like to sell ${$Item1Count} ${$Item1Name} for ${$Item1ValueRounded}?", array["Yes", "No"]);
if $sell == 0 then
//remove the item from the sell slot
widget["Sell_Widget"].element["0001"].item = null;
//add the final cost to the player currency
player.stat["currency"] += num($Item1ValueRounded);
end;
end;