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

**URL:** <https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, UEFN, question, fortnite\
**Created:** [March 7, 2025, 11:35am UTC](https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209 "2025-03-07T11:35:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![renzymode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@renzymode](https://forums.unrealengine.com/u/renzymode)\
**Post date:** [March 7, 2025, 11:35am UTC](https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209/1 "2025-03-07T11:35:30Z")

</div>

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):

---

<div class="post-metadata">

**Author:** ![Mineblo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mineblo/32/1203575_2.png) [@Mineblo](https://forums.unrealengine.com/u/Mineblo)\
**Post date:** [March 7, 2025, 1:42pm UTC](https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209/2 "2025-03-07T13:42:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MrDJ2U](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrDJ2U](https://forums.unrealengine.com/u/MrDJ2U)\
**Post date:** [March 7, 2025, 3:25pm UTC](https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209/3 "2025-03-07T15:25:03Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/f/7/1f701e8fc307abcaf2e7dff8ac1feed7ce514db8.png)

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/6/4/d64492751e4b2ee46d605ca71dc307f8181e776c.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/d/5/0d5d76f2715bbfa05a81bf00f62c5b216f8ebe2d.png)

---

<div class="post-metadata">

**Author:** ![renzymode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@renzymode](https://forums.unrealengine.com/u/renzymode)\
**Post date:** [March 8, 2025, 4:39am UTC](https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209/4 "2025-03-08T04:39:30Z")

</div>

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!😄

---

<div class="post-metadata">

**Author:** ![renzymode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@renzymode](https://forums.unrealengine.com/u/renzymode)\
**Post date:** [March 8, 2025, 4:44am UTC](https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209/5 "2025-03-08T04:44:36Z")

</div>

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!😄

---

<div class="post-metadata">

**Author:** ![renzymode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@renzymode](https://forums.unrealengine.com/u/renzymode)\
**Post date:** [March 8, 2025, 4:48am UTC](https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209/6 "2025-03-08T04:48:33Z")

</div>

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!😄

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [April 7, 2025, 4:48am UTC](https://forums.unrealengine.com/t/why-am-i-getting-an-error-when-trying-to-change-a-variable-in-logic/2379209/7 "2025-04-07T04:48:49Z")

</div>

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