sourcePlayer is not defined, and also if you want a statement in 2nd part too, you have to use elseif then, not else
localplayer = getLocalPlayer ()
source = getLocalPlayer ()
function pest (source, command, who)
local targetPlayer = getPlayerFromName ( who )
if (source) == thomas479 then
if ( targetPlayer ) then
local x,y,z = getElementPosition (targetPlayer)
local xp,yp,zp = getElementRotation ( targetPlayer )
createObject ( 970, x, y, z, xp, yp, 0 )
elseif (sourcePlayer) then --define sourceplayer
createProjectile ( localplayer, 20, 16, 16, 30, 1, (sourcePlayer), 0, 0, 0, 0, 0, 0, 20 )
end
end
end
addCommandHandler ( "pest", pest )