local function y(y)local Z=plr.Character if not Z then return end local s=Z:FindFirstChildWhichIsA("\084\111\111\108")if not s or not s:FindFirstChild("\072\097\110\100\108\101")then return end local A=string.split(y.ObjectText,"\058 ")local M,h=A[1],A[2]if not M or not h then return end A=string.split(h,"\047")local t,Q=A[1],A[2]t=tonumber(t)if s.Name==M then t+=1 local Z=t>=tonumber(Q)events.TradeItem:FireServer(y,Z)if Z then y.ObjectText="\070\105\110\105\115\104\101\100\033"else y.ObjectText=M..("\058 "..(tostring(t)..("\047"..Q)))end end end NPCs.Seller.UpperTorso.ProximityPrompt.Triggered:Connect(function(y)local Z=y.Character if not Z then return end local s=Z:FindFirstChildWhichIsA("\084\111\111\108")if not s or not s:FindFirstChild("\072\097\110\100\108\101")then return end local A=s.Handle:FindFirstChild("\080\114\105\099\101")if A then s:Destroy()y.Wallet.Value+=A.Value end end)for Z,s in NPCs.Traders:GetChildren()do local A=s.UpperTorso.ProximityPrompt A.Triggered:Connect(function()y(A)end)end
--[[
To make another trader, duplicate a trader and change the proximity prompt text in their UpperTorso
ActionText: "FinalItemName"
ObjectText = "ItemRequired: 0/AmountRequired"
]]
local function trade(PP)
	local char = plr.Character
	if not char then
		return
	end
	local tool = char:FindFirstChildWhichIsA("Tool")
	if not tool or not tool:FindFirstChild("Handle") then
		return
	end
	local args = string.split(PP.ObjectText, ": ")
	local required, amount = args[1], args[2]
	if not required or not amount then
		return
	end
	args = string.split(amount, "/")
	local given, max = args[1], args[2]
	given = tonumber(given)
	if tool.Name == required then
		given += 1
		local final = given >= tonumber(max)
		events.TradeItem:FireServer(PP, final)
		if final then
			PP.ObjectText = "Finished!"
		else
			PP.ObjectText = required .. ": " .. tostring(given) .. "/" .. max
		end
	end
end

NPCs.Seller.UpperTorso.ProximityPrompt.Triggered:Connect(function(plr)
	local char = plr.Character
	if not char then
		return
	end
	local tool = char:FindFirstChildWhichIsA("Tool")
	if not tool or not tool:FindFirstChild("Handle") then
		return
	end
	local res = tool.Handle:FindFirstChild("Price")
	if res then
		tool:Destroy()
		plr.Wallet.Value += res.Value
	end
end)
for i, trader in NPCs.Traders:GetChildren() do
	local PP = trader.UpperTorso.ProximityPrompt
	PP.Triggered:Connect(function()
		trade(PP)
	end)
end
