# How do I make a random dice roll

Get help using Construct 2

### » Sat Jul 04, 2015 3:28 pm

my aim is simple but im not very good witht he event system as i am new. The goal is to press a but and have my dye picture show a text of an integer randomly 1-6 i tried giving it a variable "Value" and randomly generate with "Set Text to random(6)" but it appears as a float im not sure why
B
11
S
3
Posts: 25
Reputation: 1,306

### » Sat Jul 04, 2015 3:52 pm

random() is always a float.
round(random(6)) = 0-6 Attention, 0 and 6 have only half chance, as opposed to the other numbers.
floor(random(6)) = 0-5 || int(random(6)) = 0-5
ceil(random(6)) = 1-6

Set text to str(ceil(random(6)))

random(x)
Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
11
S
4
G
1
Posts: 158
Reputation: 1,328

### » Fri Jul 10, 2015 6:17 pm

thank you !!!
B
11
S
3
Posts: 25
Reputation: 1,306

### » Fri Jul 10, 2015 7:05 pm

another option would be to set the text to choose(1,2,3,4,5,6)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Sat Jul 11, 2015 6:20 pm

Dice? Here the sample with dice animation: https://dl.dropboxusercontent.com/u/659 ... _dadu.capx
B
122
S
53
G
24
Posts: 794
Reputation: 23,917