KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 06:46 PM |
If I want a brick's reflectance to be anything between 0 and 1, randomly, how would I do that? I thought it was this:
brick.Reflectance = math.random(0,1)
But that just makes it either 0 or 1, nothing in between. |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 06:54 PM |
brick.Reflectance = math.random(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1)
|
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 06:56 PM |
| I had tried that earlier, just tried it again, it doesn't work. Output says "Wrong number of arguments". |
|
|
| Report Abuse |
|
|
Apatheia
|
  |
| Joined: 16 Aug 2013 |
| Total Posts: 198 |
|
| |
|
08C
|
  |
| Joined: 26 Jan 2013 |
| Total Posts: 847 |
|
| |
|
|
| 20 Sep 2013 06:59 PM |
| brick.Reflectance = toint('0.' .. math.random(-1, 10)) + 0.1 |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 06:59 PM |
try this I'm a beginner at Lua so sorry -
brick.Reflectance = 0 wait (1) brick.Reflectance = 0.5 wait (1) brick.Reflectance = 0.6 wait (1) brick.Reflectance = 0.7 wait (1) brick.Reflectance = 0.8 wait (1) brick.Reflectance = 0.9 wait (1) brick.Reflectance = 1
--This should make it so that after every 1 second, the brick reflectance will vary. |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 06:59 PM |
Sorry about that, this'll fix it:
brick.Reflectance = tonumber('0.' .. math.random(-1, 9)) + 0.1 |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 07:00 PM |
| Apath, it isn't just math.random. |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 07:03 PM |
Try mine? :D
08C with his unneeded nooby function, which doesn't even cover fully 1 to 10. |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 07:03 PM |
| doesn't even fully cover 0 to 1* |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 07:04 PM |
I'm using this in a random part generator by the way.
Will, I am using yours, and it'll work, though it randomly breaks while in function. I assume that's a problem on my end.
Output: attempt to perform arithmetic on nil value
My script:
boxy = script.Parent
function onBox() local brick = Instance.new("Part") brick.Parent = game.Workspace brick.Position = script.Parent.Position brick.Reflectance = tonumber('0.' .. math.random(-1, 9)) + 0.1 brick.BrickColor = BrickColor.Random() brick.Size = Vector3.new(2,2,2) brick.TopSurface = "Smooth" brick.BottomSurface = "Smooth" end
while wait(3) do onBox() end |
|
|
| Report Abuse |
|
|
Apatheia
|
  |
| Joined: 16 Aug 2013 |
| Total Posts: 198 |
|
|
| 20 Sep 2013 07:05 PM |
Holy...
The amount of stupidity in this post is over 9000...
Please ignore every other answer.
math.random called without arguments return a random number between 0 and 1, not an int between the first and second argument.
print(math.random(), math.random(), math.random())
> 0.0012512588885159 0.56358531449324 0.19330423902097 |
|
|
| Report Abuse |
|
|
Apatheia
|
  |
| Joined: 16 Aug 2013 |
| Total Posts: 198 |
|
|
| 20 Sep 2013 07:06 PM |
boxy = script.Parent
function onBox() local brick = Instance.new("Part") brick.Parent = game.Workspace brick.Position = script.Parent.Position brick.Reflectance = math.random() brick.BrickColor = BrickColor.Random() brick.Size = Vector3.new(2,2,2) brick.TopSurface = "Smooth" brick.BottomSurface = "Smooth" end
while wait(3) do onBox() end |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 07:06 PM |
@Apatheia
ujelly of mah script. |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 07:09 PM |
Apath, where it did not work before, it does now.
I had a typo in disguise.
It works perfectly now, thanks. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Sep 2013 07:11 PM |
OMG Is apath the ONLY one here who knows anything?
"Just math.random() ..." IS THE BEST WAY |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 07:13 PM |
@cntkillme
ujelly of mah script, 2. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Sep 2013 07:18 PM |
| Roblox:GetForumByID(20):GetAccount("WillScriptForFood"):Eat() |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 07:19 PM |
| i am to skny 2 eat cujz no1 feedz me |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 20 Sep 2013 07:20 PM |
ur output is:
Error Get! Too skinny! |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|