|
| 22 Jun 2013 09:39 AM |
Im making a flying egg using body velocity,and i want it to wait 16 seconds when the first for loop is done,then fly in a different direction. i do this by making the "Number" value negative,but everytime i do it says "Bad argument #1 to "random" (interval is empty),I know is says this because its negative,but,how can i make it negative? script: math.randomseed (tick()) script.Speed.Value = math.random (50) for i = 1,10 do wait(1) local Velocity = script.Parent.BodyVelocity Velocity.velocity = Vector3.new (math.random(script.Speed.Value),math.random(script.Speed.Value),math.random(script.Speed.Value)) print (script.Speed.Value) script.Number.Value = math.random (4) if script.Number.Value == 1 then script.Parent.Sound2:play() else script.Parent.Sound:play()
end end script.Parent.BodyVelocity.velocity = Vector3.new (0,0,0) wait(16) math.randomseed (tick()) script.Speed.Value = -50 - math.random(10) for i = 1,10 do wait(1) local Velocity = script.Parent.BodyVelocity Velocity.velocity = Vector3.new (math.random(script.Speed.Value),math.random(script.Speed.Value),math.random(script.Speed.Value)) print (script.Speed.Value) script.Number.Value = math.random (4) if script.Number.Value == 1 then script.Parent.Sound2:play() else script.Parent.Sound:play()
end end |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2013 09:41 AM |
math.random(-50,-40) You can use negative numbers just like you can positive. |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2013 09:52 AM |
And if you couldn't, you could've just done
value = 0 - value
To change it to negative before you use it. |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 10:23 AM |
Blue,You cant,Thats what i tried already,but it only wants positive intergers for some reason... True,i Tried also... Sorry for my accidental arrogance,if there is any here... |
|
|
| Report Abuse |
|
|
doneyes
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 3466 |
|
| |
|
|
| 23 Jun 2013 11:38 AM |
There's a ton of ways to do it
local x0 = -math.random(10, 40) local x1 = math.random(10, 40)*-1 local x2 = math.random(-40, -10) local x3 = -(10+(math.random()*30)) |
|
|
| Report Abuse |
|
|