Clientside poseparameter glitching

I’m trying to set poseparameters clientside for later use with aircraft flaps. It works fine serverside, however it glitches out when on the client. I use a snippet of code to test this, shown below.

local e,n e=player.GetAll()[1]:GetEyeTraceNoCursor().Entity n=0 hook.Add("Think", "test", function() n=n+0.01 if n>=1 then n=0 end e:SetPoseParameter("switch", n) end)

In the video, I run the snippet of code on the server first, then on the client. As you can see it glitches when ran on the client. This is obviously because the server overrules the client with this sort of thing, but is there a way to fix it?