generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: math.random Reflectance Help

Previous Thread :: Next Thread 
KodakKid3 is not online. 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
airplanejoe is not online. airplanejoe
Joined: 19 Oct 2011
Total Posts: 5767
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 is not online. 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 is not online. Apatheia
Joined: 16 Aug 2013
Total Posts: 198
20 Sep 2013 06:58 PM
Just math.random() ...
Report Abuse
08C is not online. 08C
Joined: 26 Jan 2013
Total Posts: 847
20 Sep 2013 06:58 PM
[ Content Deleted ]
Report Abuse
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
20 Sep 2013 06:59 PM
brick.Reflectance = toint('0.' .. math.random(-1, 10)) + 0.1
Report Abuse
airplanejoe is not online. airplanejoe
Joined: 19 Oct 2011
Total Posts: 5767
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
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
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 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
20 Sep 2013 07:00 PM
Apath, it isn't just math.random.
Report Abuse
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
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
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
20 Sep 2013 07:03 PM
doesn't even fully cover 0 to 1*
Report Abuse
KodakKid3 is not online. 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 is not online. 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 is not online. 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
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
20 Sep 2013 07:06 PM
@Apatheia

ujelly of mah script.
Report Abuse
KodakKid3 is not online. 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 is not online. 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
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
20 Sep 2013 07:13 PM
@cntkillme

ujelly of mah script, 2.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Sep 2013 07:15 PM
Ya, no
Report Abuse
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
20 Sep 2013 07:17 PM
ye, u agreed
u r
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Sep 2013 07:18 PM
Roblox:GetForumByID(20):GetAccount("WillScriptForFood"):Eat()
Report Abuse
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
20 Sep 2013 07:19 PM
i am to skny 2 eat cujz no1 feedz me
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Sep 2013 07:19 PM
NNNNNNNNNNNNNo
Report Abuse
WillScriptForFood is not online. WillScriptForFood
Joined: 03 Aug 2013
Total Posts: 701
20 Sep 2013 07:20 PM
ur output is:

Error Get!
Too skinny!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Sep 2013 07:22 PM
error("LOL NO")
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image