This won’t work as generally speaking sclang simply tells scsynth the instructions on how to build and play a synth and scysnth can only work with Ugens. When scsynth receives the instruction for
{Pan2.ar(PinkNoise.ar, f.value, level: 0.1)}.play
it doesn’t work because f.value
is function within sclang
that can not run on scsynth
as it is not defined through UGens.
It is really worth reading the docs concerning the separation between Client and Server because many problems at the beginning originate from this
https://doc.sccode.org/Guides/ClientVsServer.html
This doesn’t mean that the proposed workflow is not possible, you simply need to build a channel from which sclang can set values on scsynth, this can be either done through a parameter
// see NamedControl in the docs
x = {Pan2.ar(PinkNoise.ar, \pan.kr(0.0), level: 0.4)}.play
(
Tdef(\panChaos, {
100.do({|i|
x.set(\pan, [-1.0, 1.0].choose);
0.1.wait;
});
}).play;
)
or through a Bus which can be shared among many Synths
// create a new bus
b = Bus.control(s, 1);
// reference it within a SynthDef by using its .kr method
x = {Pan2.ar(PinkNoise.ar, b.kr(1), level: 0.4)}.play
(
Tdef(\panChaos, {
100.do({|i|
b.set([-1.0, 1.0].choose);
0.1.wait;
});
}).play;
)
BTW, just for completion, you could write the proposed code in UGen only 
Either by using a Sample and Hold approach
Ndef(\noisePan, {
Pan2.ar(
in: PinkNoise.ar,
pos: Latch.ar(
in: ClipNoise.ar,
trig: Impulse.ar(freq: \panFreq.kr(10.0)),
),
level: \amp.kr(0.1),
);
}).play.gui;
or by using Demand Ugens which work a bit like patterns or a sequencer, but running as UGens on the server which have the nice benefit that they can run at any given speed 
(
Ndef(\noisePanDemand, {
Pan2.ar(
in: PinkNoise.ar,
pos: Demand.kr(
trig: Impulse.kr(10.0),
reset: 0,
demandUGens: Drand([-1.0, 1.0], repeats: inf),
),
level: \amp.kr(0.1),
);
}).play;
)