Setting a variable to a instance's property won't work

I’m not sure if this a engine bug but for example:

local a = workspace.CurrentCamera.FieldOfView
a = 120

that won’t work but this will:

local a = workspace.CurrentCamera
a.FieldOfView = 120

This is a problem because I’m making a module script but this keeps getting in the way!

Please share a possible solution to this! ;D

I believe this is cause you’re saving the property of the FieldOfView, so a by default in your first example would save a Number value of 120

But if you reference just the CurrentCamera Instance alone, you’ll be able to access any of its properties anywhere

FieldOfView is a number, in lua numbers don’t get passed by reference,they get passed by value so

a = CurrentCamera.FieldOfView
--> a now = 120 not a reference to CurrentCamera.FieldOfView

In other languages you can set whether you are passing something by reference or value but not in lua


2 Likes