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()

Previous Thread :: Next Thread 
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Sep 2011 05:35 PM
while true do
wait(1)
for i,v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "Part" then
v.Transparency = math.random()
if v.Transparency == 1 then
i.CanCollide = false
i.Parent = game.Lighting
end
end
end
end

That works.Like the Transparency is random.But it doesn't do the part where if the Transparency is 1 the CanCollide is false and The Parent Isn't Lighting.:P Help?

I've also tried
v.CanCollide = false
v.Parent = game.Lighting
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
09 Sep 2011 05:36 PM
"v.Transparency = math.random()
if v.Transparency == 1 then
i.CanCollide = false
i.Parent = game.Lighting"

you put i for the second one and that's just the index.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
09 Sep 2011 05:37 PM
I don't believe the transparency will ever be 1. math.random() alone returns a number between 0 and 1

~{::Epic Hologram Maker::}~
~http://www.roblox.com/Hologramizer-item?id=60142277
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Sep 2011 05:39 PM
@Swimguy

Your no help -__-

@SDuke

That's the same thing I said....And it doesn't work -__-
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
09 Sep 2011 05:40 PM
He told you the answer. math.random() returns a whole number, no decimals. AND you didn't even fill in the arguement spaces.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
09 Sep 2011 05:40 PM
v.Transparency = math.random()
if v.Transparency == 1 then

v.Transparency will never be 1, therefore, anything in the if statement will NOT run. Thus, your problem.

~{::Epic Hologram Maker::}~
~http://www.roblox.com/Hologramizer-item?id=60142277
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
09 Sep 2011 05:41 PM
I pointed out the problem I didn't fix it for you.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
09 Sep 2011 05:41 PM
@Dark

math.random() works with no arguments. It returns a decimal between 0 and 1.

~{::Epic Hologram Maker::}~
~http://www.roblox.com/Hologramizer-item?id=60142277
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
09 Sep 2011 05:43 PM
...It does? But.. >.> Agh! Everything I know is a lie!
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Sep 2011 05:47 PM
OH really?Wait, math.random() doesn't come to 1?Hmm, what if I said

v.Transparency = math.random(.1,1)
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
09 Sep 2011 05:48 PM
How about...
v.Transparency = math.random(1,100)/100
if v.Transparency == 1 then

~{::Epic Hologram Maker::}~
~http://www.roblox.com/Hologramizer-item?id=60142277
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Sep 2011 06:04 PM
Wouldn't that only go to 1 as a fact that a 100/100 = 1?
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
09 Sep 2011 06:05 PM
Yes. You could use math.random(1,10)/10 for a better chance of getting 1, but less random random numbers.

~{::Epic Hologram Maker::}~
~http://www.roblox.com/Hologramizer-item?id=60142277
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Sep 2011 06:08 PM
But I want it to go to .1-1 not 0,1 or 1 :o
Report Abuse
Cachinnation is not online. Cachinnation
Joined: 21 Aug 2011
Total Posts: 1797
09 Sep 2011 06:09 PM
v.Transparency = 0 or 1

you mean that?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Sep 2011 06:09 PM
@Chach

No, I want math.random--From 0 - 1 WITH decimals.
Report Abuse
Cachinnation is not online. Cachinnation
Joined: 21 Aug 2011
Total Posts: 1797
09 Sep 2011 06:10 PM
Just use the generic for loop...
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
09 Sep 2011 06:11 PM
@miz

math.random(1,10) returns any number from 1 to 10. Now divide it by 10. So if we get

8
8/10 = .8

Or
1
1/10 = .1

Or 10
10/10 = 1

~{::Epic Hologram Maker::}~
~http://www.roblox.com/Hologramizer-item?id=60142277
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
09 Sep 2011 06:11 PM
You could use a table.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
09 Sep 2011 06:12 PM
@dark

Whachoo talkin bout willis?

~{::Epic Hologram Maker::}~
~http://www.roblox.com/Hologramizer-item?id=60142277
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
09 Sep 2011 06:12 PM
for i=1,10 do
script.Parent.Transparency=tostring"."..i
wait(.1)
end

?

­<'+1 Post. Ujelly?'>
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
09 Sep 2011 06:13 PM
values = {0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1)

local random = values[math.random(1,#values)]

script.Parent.Transparency = random
Report Abuse
Cachinnation is not online. Cachinnation
Joined: 21 Aug 2011
Total Posts: 1797
09 Sep 2011 06:14 PM
Or you could do the very inefficient way...

v.Transparency = 0 or 0.1 or 0.2 or 0.3 or .4 or .5 or .6 or .7 or .8 or .9 or 1
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
09 Sep 2011 06:20 PM
while wait(.1) do
script.Parent.Transparency="."..math.random(1,10)
end

Dat?

­<'+1 Post. Ujelly?'>
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Sep 2011 06:25 PM
I like Cach script if it works :D
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