Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Random brick spawning script broken?

Asked by 9 years ago
1Part = 1
2Wedge = 2
3Cylinder = 3   
4 
5    while true do
6        Instance.new(math.random(1,2,3))
7wait(.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

1 answer

Log in to vote
1
Answered by 9 years ago

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 
03Objects = { --Define the different objects
04"Part",    --Index of 1
05"Wedge"--Index of 2
06"Cylinder"   --Index of 3
07}
08 
09 --[[
10objects[1]  would return "Part"
11objects[2]  would return "Wedge"
12objects[3]  would return "Cylinder"
13 
14Instance.new(objects[1])  would create a new part.
15Instance.new(objects[2])  would create a new wedge.
View all 31 lines...
0
To add onto this I suggest doing while wait(0.5) do then have an end it just cleans up nicer Prioxis 673 — 9y
0
^ jordan0810 55 — 9y
0
^ Vezious 310 — 9y
Ad

Answer this question