Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 01 Sep 2011 09:03 AM |
I been trying to figure out how to use math.random using this line i think its in correct. can you help?
function Click()
for i=1,10 do
game.Lighting.(math.random(Brick1).math.random(Brick2)).Position = game.Workspace.(math.random(Brick1).math.random(Brick2)).ck1.Position + Vector3.new(1,1,1) wait(3) end i= -6
script.Parent.MouseButton1Down:connect(Click)
The script is in a Textbutton. Can you fix it? |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 01 Sep 2011 09:04 AM |
| Oh I forgot, The script is trying to choose which one will go to (1,1,1). Its uses math.random to choose either Brick1 or Brick2 to move to Vector3.new(1,1,1) |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 01 Sep 2011 09:05 AM |
Kind of messed up.. If you want random part there is sume ussefull stuff:
c = game.Workspace:GetChildren()
randomPart = c[math.random(1,c)] |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 01 Sep 2011 09:05 AM |
Oh I forgot, The script is trying to choose which one will go to (1,1,1). Its uses math.random to choose either Brick1 or Brick2 to move to Vector3.new(1,1,1)
I hate flood check! 5x OMG |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 01 Sep 2011 09:08 AM |
You did it wrong. The math random works only with numbers. Do example what i did. You can do it with any table soo you can do this too:
table = {part1,part2} randomPart = table[math.random(1,#table)] |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 01 Sep 2011 09:12 AM |
Ok, so when I use your table,
table = {part1,part2} RandomPart = table[math.random(1,#table)]
game.Lighting.RandomPart.Position = game.Lighting.Brick1.Position + Vector3.new(1,1,1)
Is this right? |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 01 Sep 2011 09:15 AM |
depens how you do it. Two ways how:
table = {game.Lighting.Part1,game.Lighting.Part2} r = table[math.random(1,#table)] r.Position.............
Or other way:
table = {"Part1","Part2"} r = table[math.random(1,#table)] game.Lighting[r].Position............. |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 01 Sep 2011 09:23 AM |
table = {game.Lighting.Part1,game.Lighting.Part2} miro = table[math.random(1,#table)]
function Click()
for i=1, 10 do game.Lighting.miro.Position = game.miro.Position + Vector3.new(1,1,1) wait(3) end i = -6 end
script.Parent.MouseButton1Down:connect(Click)
there. Does it work now? |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
| |
|
|
| 01 Sep 2011 09:57 AM |
miro is not a valid member of Lighting.
Your variable is already in Lighting. If your syntax was correct, you would be doing game.Lighting.game.Lighting.Part1.
table = {game.Lighting.Part1,game.Lighting.Part2} miro = table[math.random(1,#table)]
function Click()
for i=1, 10 do miro.Position = miro.Position + Vector3.new(1,1,1) wait(3) end end
script.Parent.MouseButton1Down:connect(Click) |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 01 Sep 2011 10:57 AM |
table = {game.Lighting.Part1,game.Lighting.Part2} miro = table[math.random(1,#table)]
function Click()
for i=1, 10 do miro.Position = miro.Position + Vector3.new(1,1,1) wait(3) end i= -6 end
script.Parent.MouseButton1Down:connect(Click)
I just wanted more to be inserted when every loop finish |
|
|
| Report Abuse |
|
|
|
| 01 Sep 2011 10:59 AM |
LOL! LOL! LOL!
That won't help you, bud. LOL! |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 01 Sep 2011 11:04 AM |
| But I want unlimited..D: well im making an unlimited wave GUI but do you think i should make 2000x like this? |
|
|
| Report Abuse |
|
|
|
| 01 Sep 2011 11:19 AM |
repeat
ST00F
until false
That is an infinite loop. OR, you can do this
while true do
ST00F
end
Make sure you have a wait there. It will crash your game otherwise. |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 01 Sep 2011 12:20 PM |
Well i cant use some of them in a MouseButton1Down event right? Which one? |
|
|
| Report Abuse |
|
|