Textbox sending to both players

Hey all,
Got a little problem where my Usermessage is being sent to both players, which I only want it to send to the person infront of them, Here is the code:

function Finethem(ply, args)
local pos = ply:GetShootPos()
local ang = ply:GetAimVector()
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos+(ang*80)
tracedata.filter = ply
local trace = util.TraceLine(tracedata)
if trace.Entity:IsPlayer() then

price = tonumber(args)
name = tostring(trace.Entity:Nick())
local receiver = FindReceiver(name)
nams = tostring(receiver:Nick())

if !price then return "" end

receiver:SetPData("fineamount", price)

receiver:SetPData("finer", nams)


Notify(ply, 1, 4, string.format("Fine sent to " .. name .. "!", s))
Notify(ply, 1, 4, string.format("You are not looking at a player who cant be fined!", s))
return ""
return ""

AddChatCommand("/fine", Finethem)

function Testfine(ply)

umsg.Start( "Fines" );
umsg.String( ply:GetPData("finer") );
umsg.Float( ply:GetPData("fineamount") );

concommand.Add( “Testfine”, Testfine )


Yes the code is sloppy but its just till I get rid of this bug. Thanks for reading, Any help much appreciated.

umsg.Start() can take 2 arguments; the umsg name and a recipientfilter / player. Do this:

function Testfine(ply)
umsg.Start( “Fines”, ply );
umsg.String( ply:GetPData(“finer”) );
umsg.Float( ply:GetPData(“fineamount”) );

Works Perfectly Thanks!

You’re also using string.format, though what you do isn’t affected by that function at all.

You might want to read this page: http://wiki.garrysmod.com/?title=String.format
Or: http://wiki.garrysmod.com/?title=Format

Oh thanks for the tip :slight_smile: