# How to prevent line trace from attempting to access variable?

**URL:** <https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710>\
**Category:** Programming & Scripting\
**Tags:** Variable, line-trace, accessed-none, unreal-engine, question\
**Created:** [May 20, 2024, 12:34pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710 "2024-05-20T12:34:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 20, 2024, 12:34pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/1 "2024-05-20T12:34:46Z")

</div>

I’m not even entirely sure if this is the case but I think my line trace is attempting to access a variable or it is causing something for the variable to be accessed?

My aim is for the line trace simply hit an object, then for some relevant text to appear on screen for said object.

Here is my code for the line trace itself:

 ![image001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/4/e4423ce42489302599f9cc452da522fab0ed93da.png)

This then triggers an event within the game mode, which in turn triggers another event to occur within the user interface to change the PressKey variable from “test” to display “This works” on my user interface.

I’ve used settext (text) to alter the “Press Key” variable, which is some text on the user interface.

However when I go to test the game, the text does not change whatsoever, and instead I receive accessed none errors.

The reason I think it is because of the line trace, is that when I trigger the same piece of code by something anything other than the line trace (such as a simple F key press) it works just fine.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 20, 2024, 12:46pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/2 "2024-05-20T12:46:43Z")

</div>

Try the ‘is valid’ and the print the other way around?

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 20, 2024, 2:01pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/3 "2024-05-20T14:01:35Z")

</div>

Thanks for the response! I haven’t tried this yet but I put the print string there just to confirm that the line trace was identifying the object, I think the issue was occurring before I put the print string there.

Do you think the IsValid is causing the issue though?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 20, 2024, 2:16pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/4 "2024-05-20T14:16:03Z")

</div>

No, I think the print string is 🙂

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 20, 2024, 3:11pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/5 "2024-05-20T15:11:10Z")

</div>

I’ve just tried removing the print string and unfortunately the error still persists! Just to preface, this error only occurs when the line trace hits the object and begins executing the settext (text) code

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 20, 2024, 3:30pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/6 "2024-05-20T15:30:45Z")

</div>

Ah! - the none is coming from elsewhere then, I’m guessing…

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 20, 2024, 3:52pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/7 "2024-05-20T15:52:52Z")

</div>

Indeed! I’m just trying to understand how the line trace would be interfering with the “pressKey” variable. Since it is that variable that is coming up as the none accessed error, even though the variable has a value, which is the text.

I feel like the line trace is trying to access the “pressKey” variable as a value that isn’t what it is? Just a guess though

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 20, 2024, 4:37pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/8 "2024-05-20T16:37:42Z")

</div>

It can’t access it, because it returns an actor reference, which has no such variable.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 20, 2024, 4:41pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/9 "2024-05-20T16:41:15Z")

</div>

> [@DarkKrisSouls](#):
>
> accessed none errors

You could post the actual error message - not only does it tell it what is wrong, precisely, but is also hyperlinked and, once clicked, will take you to the offending node. There is not enough script shown to determine what is going on.

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 20, 2024, 5:14pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/10 "2024-05-20T17:14:16Z")

</div>

Apologies I tried to send the images in the original post but it didn’t allow me since I’m a new user ahah. But here’s the error message below!

 ![image014](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/8/298166f847132ad3882ee4bdb5a10962b3f7fed5.jpeg)

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 20, 2024, 5:15pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/11 "2024-05-20T17:15:58Z")

</div>

![image013](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/1/531c3bce21e747153c4c1b261e840c74fe172abb.jpeg)

Here is also the script for the user interface, where the error message takes me

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 20, 2024, 5:36pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/12 "2024-05-20T17:36:02Z")

</div>

So, what is `Press Key`, really? Did you create a new variable without giving it value? Because that’s not going to work.

* * *

In the widget with the text block:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/4/9e4c6a9dbda64e2bd46abba2e88e5ac88b530529.png)

Ensure it’s ticked - it will expose this native element to scripting and allow you to set its data:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/7/5/e7527f9e33d88f768916262ef8fb8f11a1f3b433.png)

No need to create additional variables.

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 20, 2024, 5:58pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/13 "2024-05-20T17:58:58Z")

</div>

Sorry I really haven’t explained this very well 😅 I’m really a rookie in this, it’s my bad for doing such a bad job with this question!

The variable isn’t created out of nowhere however, it is a piece of text on the user interface that has been checked as “is variable” and given the name pressKey

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 20, 2024, 6:00pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/14 "2024-05-20T18:00:30Z")

</div>

Furthermore the script works exactly as intended when this whole series of events is triggered by something simple like a key press. But when it is triggered by the line trace, it comes up with this error

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 20, 2024, 8:32pm UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/15 "2024-05-20T20:32:02Z")

</div>

Could you show the rest of the script then, what does the line trace actually trigger?

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 21, 2024, 10:39am UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/16 "2024-05-21T10:39:42Z")

</div>

So the line trace is effectively a crosshair for the player. When they look at an object, they will be able to interact with it.

This is what follows the line trace script:

 ![image002](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/9/6/b964e8ed8cfaeb4edd1063f25536b9f36c18ce48.png)

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 21, 2024, 10:40am UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/17 "2024-05-21T10:40:16Z")

</div>

Which in turn triggers this

 ![image011](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/1/b/21b9d49ef274070c9b767863a73427514b05410e.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 21, 2024, 11:00am UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/18 "2024-05-21T11:00:39Z")

</div>

Now that we see the entire picture, it all seems fine indeed. We’ll need to look at the stuff we cannot see here.

* * *

Could we see the widget hierarchy and the list of its variables?

---

<div class="post-metadata">

**Author:** ![DarkKrisSouls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DarkKrisSouls](https://forums.unrealengine.com/u/DarkKrisSouls)\
**Post date:** [May 21, 2024, 11:36am UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/19 "2024-05-21T11:36:24Z")

</div>

Of course! Here is the widget hierarchy. The only variable is “pressKey”

 ![image001](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/4/3/143fd2bda99de042396ccb10d5957370388cc334.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 21, 2024, 11:50am UTC](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710/20 "2024-05-21T11:50:15Z")

</div>

> [@Everynone](#):
>
> the list of its variables

Can we see the details panel, like so:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/a/2/8a21817664a2318fbd3e65b21f7f188c3cb48a68.png)

[Next page](https://forums.unrealengine.com/t/how-to-prevent-line-trace-from-attempting-to-access-variable/1864710.md?page=2)
