Override local vars?

Short question: Can I modify local vars in a function without overwriting the complete function?
I don’t care how complicated it can be.

No, Local vars are, well, local. Else it would ruin their existance.

debug.setlocal

debug.setupvalue

@man with hat
I didn’t really get all locals with debug.getupvalue.
This didn’t work for me.

Can you give me a example with debug.getlocal.
If I have for example this function:



function myfunc()
   local trace = LocalPlayer():GetEyeTrace()
   if bla then
      trace = something
   end
end


upvalues are for local variables created outside of the function, but the function uses. I can’t see your full code, but I’m guessing that won’t work in this case, and getlocal needs the function to be in the stack in order to get its local variables. If it isn’t, then you’ll only be able to access the name of its parameters.