1 | Part = 1 |
2 | Wedge = 2 |
3 | Cylinder = 3 |
4 |
5 | while true do |
6 | Instance.new(math.random( 1 , 2 , 3 )) |
7 | wait(. 5 ) |
8 | end |
It's supposed to create a random brick that is either Part, Wedge or cylinder.
Part of an exercise I am doing. Thank you! :D
Good attempt but you have used math.random incorrectly and your variables are useless.
In your code you have told math.random to start at 1, end at 2 and increment by 3 each time. (Which is impossible!) Math.random should be used like this: math.random(starting number, end number, [increment])
Your variables are not getting used in your code so i have replaced them with an array (table)
Below i have changed and fixed your code.
01 | --NilLogic |
02 |
03 | Objects = { --Define the different objects |
04 | "Part" , --Index of 1 |
05 | "Wedge" , --Index of 2 |
06 | "Cylinder" --Index of 3 |
07 | } |
08 |
09 | --[[ |
10 | objects[1] would return "Part" |
11 | objects[2] would return "Wedge" |
12 | objects[3] would return "Cylinder" |
13 |
14 | Instance.new(objects[1]) would create a new part. |
15 | Instance.new(objects[2]) would create a new wedge. |