System scheduler problem

Hello,
I have a problem that I have a script which getting stats from routers interface wireless reg table.
It works OK. But there is a problem that if I run this script from scheduler nothing happen. Run count is increased but I am creating a file in script so I see that nothing happen. Anyone know how to fix it? I paste here a begin of a code to see if there is no problem.

:local MAC ""
:local clientcount [:len [/interface wireless registration-table find]]
:local count 0
:local countrtx 0
:local value ""
:local findindex 0
:local Rx 0
:local Tx 0
:local RxTx ""
:local deltaRx 0
:local deltaTx 0
:local n 1

:if ($clientcount > 0) do={
	:for i from=0 to=($clientcount - 1) step=1 do={
		:set count 0
		:set MAC [/interface wireless registration-table get number=$i mac-address]
		:set value [/interface wireless registration-table get number=$i bytes]

I think problem is when Im setting MAC and value that there is nothing but numbers of clients is 1 because Im joined. I also tried it in console and everything ok. Could someone help me?