# Variables between scripts

**URL:** https://discussions.unity.com/t/variables-between-scripts/421358
**Category:** Scripting
**Tags:** Scripting
**Created:** [August 24, 2010, 8:11pm UTC](https://discussions.unity.com/t/variables-between-scripts/421358 "2010-08-24T20:11:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_1875800](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@anon\_1875800](https://discussions.unity.com/u/anon_1875800)
#### Post date: [August 24, 2010, 8:11pm UTC](https://discussions.unity.com/t/variables-between-scripts/421358/1 "2010-08-24T20:11:16Z")

</div>

Hello, I’m having trouble effecting a variable from script A using script B.

My situation is that I have a coroutine using a variable, but I also want to have an update function so I can have the variable change every second. It threw up an error when I put an update function in the same script as a coroutine, so I moved it to a different script.  
I tried making the variable in question a global variable, but it didn’t work as I had intended it. How else might I effect a variable in one function from another?  
Any help would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![BlackMantis](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/blackmantis/32/593530_2.png) [@BlackMantis](https://discussions.unity.com/u/BlackMantis)
#### Post date: [August 25, 2010, 10:22am UTC](https://discussions.unity.com/t/variables-between-scripts/421358/2 "2010-08-25T10:22:32Z")

</div>

I had the same problem a couple of times. Try another var on script one that is static and outside your coroutine try to convert/= the static var that can be controlled by the update function on script B.

If you need to call the function every second you can just use Invoke. 😄
