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 » Scripters
Home Search
 

Re: Random X, Y, X Values???

Previous Thread :: Next Thread 
RoboGean is not online. RoboGean
Joined: 24 Mar 2011
Total Posts: 577
02 Jan 2015 09:42 PM
Would this work? If not, what WOULD work?

local sp = script.Parent

local size = sp.Size

function change()
size = (math.Random(1-5)),(math.Random(1-5)),5 --Keeping the Z value the same
end

while true do
wait()
loop()

end

I'm just wanting to know if this would work
Report Abuse
RoboGean is not online. RoboGean
Joined: 24 Mar 2011
Total Posts: 577
02 Jan 2015 09:44 PM
Whoops, on the last bit, pretend the "loop()" part isn't there
Report Abuse
Poloboy567 is not online. Poloboy567
Joined: 24 Jun 2008
Total Posts: 62
02 Jan 2015 09:52 PM
Working script:

function change()
local sp = script.Parent
local randomvalue = math.random(1,5)
sp.Size = Vector3.new(randomvalue,randomvalue,5) --Keeping the Z value the same
end

while true do --Loops the change() function
change() --Fires the function to change the brick's shape
wait() --How often you want the bring to change its shape
end

Note: math.random() is always typed in lower case, and to say "from 1 to 5" you don't put (1-5). Instead, replace the dash with a comma.
Report Abuse
RoboGean is not online. RoboGean
Joined: 24 Mar 2011
Total Posts: 577
02 Jan 2015 09:55 PM
Thanks dude, do I need to keep the sp inside the function?
Report Abuse
Poloboy567 is not online. Poloboy567
Joined: 24 Jun 2008
Total Posts: 62
02 Jan 2015 10:04 PM
Nope, it'll work outside the function too.
Report Abuse
RoboGean is not online. RoboGean
Joined: 24 Mar 2011
Total Posts: 577
02 Jan 2015 10:08 PM
And that way I can use sp in other functions correct?
Report Abuse
Poloboy567 is not online. Poloboy567
Joined: 24 Jun 2008
Total Posts: 62
02 Jan 2015 10:12 PM
Yep!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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