How to stop overwriting variables?

local frame = script.(really long line).(somebool)

frame = true

How to make frame = true actually change variable and not overwrite line before?

1 Like

You can’t. Instead you do

local frame = script.(really long line)
frame.somebool = true

The reasoning is that when declaring frame to be

frame = script.(really long line).(somebool)

this makes a variable called frame take on the value that script.(really long line).(somebool) evaluates to. Since it’s probably a boolean, that’ll be either true or false. There is no way to “go back” to the property that you initially got the value from.

Doing

local frame = script.(really long line)

makes the variable frame take on the value that script.(really long line) evaluates to, probably an object in your case?

1 Like

If you want to avoid having really long lines repeated like here:

script.(really long line).(somebool) = true
script.(really long line).Name = "test"
script.(really long line).Parent = workspace

then you do it in the same manner, i.e. by declaring a variable that holds script.(really long line) and instead writing

(the variable).(somebool) = true
(the variable).Name = "test"
(the variable).Parent = workspace
How to understand the problem
local frame = script.(really long line).(somebool)

This actually just makes a variable called frame which will be a bool. Let’s say it was this:

local frame = script.Parent.Parent.Visible

Let’s say script.Parent.Parent.Visible is false. That would mean it’s basically this:

local frame = false

When you do frame = true that’s just changing the variable. Now the variable frame is true.

To fix this, It will have to be

local frame = script.(really long line)

frame.(somebool) = true

wait that doesn’t work?! how am i just finding out about this?
oh god i bumped