This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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?

in Engine by (55 points)

1 Answer

+2 votes
by (26 points)

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

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!

thank you, now it works.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.