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 question

Previous Thread :: Next Thread 
snowboarder199 is not online. snowboarder199
Joined: 15 Aug 2009
Total Posts: 2703
19 Jun 2014 10:02 PM
so im using a weld, and well... heres what i have:

local weld = Instance.new("Weld",plr.Character.Torso)
weld.Part0 = weld.Parent
weld.Part1 = b
weld.C1 = CFrame.new(0,-1,0) * CFrame.Angles(math.rad(-90),0,0)


so that works fine and dandy, and no errors there, the only issue that is bugging me is i cant set the 'weld.C1' to this:

weld.C1 = CFrame.new(math.random(-0.5,0.5),-1,math.random(-0.5,0.5)) * CFrame.Angles(math.rad(-90),0,0)
(chaning the 0's to the math.random(-0.5,0.5)'s)

if i do that, then it wont register the math.random at all and just keep it at '0,-1,0' but when i change the 0.5's to whole numbers:

weld.C1 = CFrame.new(math.random(-1,1),-1,math.random(-1,1)) * CFrame.Angles(math.rad(-90),0,0)

then the math.random is registered and works.
Is there any way to fix this?
(the parts are on a 'Custom' formFactor if it makes a difference)
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 10:05 PM
rly
Report Abuse
snowboarder199 is not online. snowboarder199
Joined: 15 Aug 2009
Total Posts: 2703
19 Jun 2014 10:06 PM
fo real homie :l

i have no clue what could be causing this either .-.
Report Abuse
Forlapse is not online. Forlapse
Joined: 07 Jan 2014
Total Posts: 122
19 Jun 2014 10:11 PM
Correct me if Im wrong, but dosnt math.random only select whole integers?
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 10:11 PM
never really worked with math.random but i dont think it can accept negative integer arguments
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 10:11 PM
*I mean accept more than 3 arguments
Report Abuse
Forlapse is not online. Forlapse
Joined: 07 Jan 2014
Total Posts: 122
19 Jun 2014 10:15 PM
So at that you might have to do:

x=math.random(-0.5,0.5)
y...
z...

But Im pretty sure it always returns as a whole number so try this:
math.random(-0.5,0.5)*100
http://wiki.roblox.com/index.php?title=Math.random
Report Abuse
snowboarder199 is not online. snowboarder199
Joined: 15 Aug 2009
Total Posts: 2703
19 Jun 2014 10:15 PM
well...

math.random(); the way im using it takes two arguements, the smallest first followed by the largest, and i know for a fact that it does work with negative integers, but you may be right forlapse, in assuming it only works with whole number integers... :l
Report Abuse
snowboarder199 is not online. snowboarder199
Joined: 15 Aug 2009
Total Posts: 2703
19 Jun 2014 10:16 PM
welp looks like i have to do this the hard way >.>


loops your supposed to be able to save me hard work not expand it ;_;
Report Abuse
DhatBoiiPapi is not online. DhatBoiiPapi
Joined: 27 May 2013
Total Posts: 701
19 Jun 2014 10:19 PM
Math.random can only accept 2 arguments. Not 3.
It can't be something like
math.random(1,10,15)
Only math.random(1,10)
Report Abuse
snowboarder199 is not online. snowboarder199
Joined: 15 Aug 2009
Total Posts: 2703
19 Jun 2014 10:21 PM
@Dh, i already knew this, i didnt have 3 arguements entered for the math.random()
i had 3 arguments entered for the CFrame Value of the Welds 'C1'
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
19 Jun 2014 11:05 PM
print(math.random(-.5,.5)) --won't work
print(math.random(-5,5)/10) --same thing, should work

math.random can only be used with integers, but you can use math to make it seem like it is getting a decimal
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
19 Jun 2014 11:08 PM
math.random(-.5,.5) --Nope.

math.random()-0.5 --Yup.
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