Can you put a stringVariable on a "."?

I have a variable “latestCamMode” that is set to a string value equal to the name of cameramodes.
So to save a bunch of if/else statements - is it possible to do what is theorized below? At the moment it is doing an error if written like this of course.

plr.CameraMode = Enum.CameraMode.latestCamMode
local val = "latestCamMode"
plr.CameraMode = Enum.CameraMode[val]
1 Like
plr.CameraMode = Enum.CameraMode[latestCamMode]

thanks. I know this question has prob been asked a lot, but it’s a difficut question to search up due to its many ways of phrasing.

For future questions you can try removing information, for example, this can be converted to “How can I convert a string to an enum”.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.