How make something random?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dezekeerjoran
:warning: Old Version Published before Godot 3 was released.

How can you make something random? Like a every time you press a button, a label shows a number in between 1 and 100. am i clear?

:bust_in_silhouette: Reply From: deathvulture


Check if this answer your question

thanks, but i am kinda a noob. i have no idea what there talking about.

dezekeerjoran | 2016-12-22 12:54

Hmmm i think you should do this tutorial first but i’ll try to help you.

First you need to create a button, then add a script and put this inside

extends Button

func _ready():

func _random():

In the ready function you connect the pressed state with the _random function.

randomize() change the seed which will generate the random number.
And the last line set the button text with a random number from 0 to 10.

Hope it helps!

deathvulture | 2016-12-22 16:24

thank you, now it works.

dezekeerjoran | 2016-12-22 18:24