Why Am I Getting an Error When Trying to Change a Variable in Logic?

I’m trying to change the value of a variable in logic, but I keep getting an error. Why?

logicA : logic = true

if(set logicA = false):

2 things, firstly to change a variable it must first actually be a variable,

You need to make logicA : logic = true to var logicA : logic = true

Secondly in this instance setting this variable is not something that can fail and thus you shouldn’t put it in a failure context (your if() ) you can just have it as set logicA = false by itself.

2 Likes

I tried that and still gave an error but I think VS code was bugging out. I closed it and reopened from UEFN and it’s working. You beat me to it. Good job!

@renzymode you may be thinking of something like this

where you’re indexing into an array or when you are casting an object. The code below the line you see the error on is a correct way to do it, as you see below with no red squigglies.
image

2 Likes

Thank you!

I learned how to work with constants and variables!

With what I have learned, I can now change the value of a variable in logic!
I am now able to change the value of a variable!

Thank you so much!:smile:

Thanks for telling me!
Thank you for making it so easy to understand, even adding pictures!

I had been unable to access the arrays until now and I didn’t know how to do that for a long time!

But now, by restarting VSCode and UEFN, I was able to solve those problems!

I’ve never had as much fun typing in Verse code as I had today! I had so much fun writing Verse code!

I was a bit tired from writing so much code, and I had some new questions, but all in all, it was a lot of fun!

All of this is thanks to the redline error solution!

Thank you so much!:smile:

The logic I used this time worked fine when I changed the constant to a variable, so I’ll take Mineblo’s solution as the best answer!

Both answers were very helpful!

Thanks to both of you for your help!:smile:

2 Likes

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