# when i press button object set random color

**URL:** <https://forums.unrealengine.com/t/when-i-press-button-object-set-random-color/437509>\
**Category:** UI\
**Tags:** button, random, logic, unreal-engine, question\
**Created:** [November 12, 2018, 9:57pm UTC](https://forums.unrealengine.com/t/when-i-press-button-object-set-random-color/437509 "2018-11-12T21:57:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![L1GHt\_qwerty](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@L1GHt\_qwerty](https://forums.unrealengine.com/u/L1GHt_qwerty)\
**Post date:** [November 12, 2018, 9:57pm UTC](https://forums.unrealengine.com/t/when-i-press-button-object-set-random-color/437509/1 "2018-11-12T21:57:27Z")

</div>

How to make it so that when you press a button, the object (cube) changes to a random color?

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [November 13, 2018, 9:40pm UTC](https://forums.unrealengine.com/t/when-i-press-button-object-set-random-color/437509/2 "2018-11-13T21:40:08Z")

</div>

First, you have to create a material with a color parameter.

 ![259315-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/6/40632c2e2ea815e8a6e67016b414174b7251ca5d.png)

Then apply this material to your cube.  
Next, do this:

 ![259316-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/8/d/b8d4a1e277ad7f935e8db96c1ef599ad4336b99d.png)

Alternatively, if you want to limit your color range somehow, you can do something like this:

 ![259317-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/4/7/647c7135a31b79a697cd3235d4ef756e1bd090a5.png)

Note that you have to enter the parameter name manually.
