# Changing variable from another class in verse

**URL:** <https://forums.unrealengine.com/t/changing-variable-from-another-class-in-verse/1616066>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite\
**Created:** [January 15, 2024, 6:44am UTC](https://forums.unrealengine.com/t/changing-variable-from-another-class-in-verse/1616066 "2024-01-15T06:44:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ButtersHQ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ButtersHQ](https://forums.unrealengine.com/u/ButtersHQ)\
**Post date:** [January 15, 2024, 6:44am UTC](https://forums.unrealengine.com/t/changing-variable-from-another-class-in-verse/1616066/1 "2024-01-15T06:44:43Z")

</div>

```auto
MyOtherClass:= class():
    ChangeMyInt():void=
    #what goes here to set/change the value of "MyInt" from "MyClass"?

MyClass := class(creative_device):

    var MyInt: int = 0

    OnBegin<override>()<suspends>:void=
        NewMyOtherClass:=MyOtherClass{}
        MyOtherClass.ChangeMyInt() 
          

```

So my question is what would I place in ChangeMyInt() to change the MyInt variable in MyClass

Side question: is it possible to avoid the “MyOtherClass.ChangeMyInt()” line, and appon creation of MyOtherClass, automatically call ChangeMyInt()

Might be a super basic question but im new 🙂

---

<div class="post-metadata">

**Author:** ![WhatsBipo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/whatsbipo/32/766507_2.png) [@WhatsBipo](https://forums.unrealengine.com/u/WhatsBipo)\
**Post date:** [January 15, 2024, 6:57pm UTC](https://forums.unrealengine.com/t/changing-variable-from-another-class-in-verse/1616066/2 "2024-01-15T18:57:48Z")

</div>

You can put a block in a class body without a function and it’ll run on creation of the class. So you’d just replace “ChangeMyInt():void=” with “block:”. The only thing to know is that anything within the block needs to be “rollback”-able just like any function in a failure context.
