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: Will this work?

Previous Thread :: Next Thread 
Gamecube44 is not online. Gamecube44
Joined: 24 Jul 2013
Total Posts: 130
06 May 2014 10:52 PM
I want to make a loot system I need math.random to pick a random position that I made for the items to spawn and I don't know if this works or not.

My code:
math.random(489, 576, 589/475, 583, 563/473, 473, 584)
Report Abuse
Vuva is not online. Vuva
Joined: 22 Jan 2010
Total Posts: 1102
06 May 2014 11:12 PM
with math.random, you can only have two parameters for the minimum and maximum random value. It would be better to put the numbers into a table, and then access a random element in the table. And also, positions should be manipulated with Vector3 values.

SomeTable={Vector3.new(489, 576, 589),Vector3.new(475, 583, 563),Vector3.new(473, 473, 584)}
RandomPosition=SomeTable[math.random(1,3)]
Report Abuse
Gamecube44 is not online. Gamecube44
Joined: 24 Jul 2013
Total Posts: 130
06 May 2014 11:45 PM
Is randomposition a real method? Yesterday I learned about the method to move models called MoveTo and it was a real method.
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
06 May 2014 11:54 PM
It can be a real method if you want it to be :D
(You have to define it and all.)

So you can't just create a news script and put blah:randomposition(somevector).
Report Abuse
Gamecube44 is not online. Gamecube44
Joined: 24 Jul 2013
Total Posts: 130
06 May 2014 11:56 PM
Aparently RandomPosition isn't a real method heres what I made:

SomeTable = {Vector3.new(489, 576, 589),Vector3.new(475, 583, 563),Vector3.new(473, 473, 584)}
workspace.Part.Position = SomeTable[math.random(1,3)]

I'm actually good at scripting I just don't know some things. Thanks for the help.
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
07 May 2014 02:16 AM
"Aparently RandomPosition isn't a real method"
No, ScrewDeath is right. You just have to believe! (and write a bunch of code)
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
07 May 2014 02:24 AM
function Random(...)
local Temp = {...}
return Temp[math.random(1, #Temp)]
end

hi = Random(Vector3.new(0, 0, 0), Vector3.new(1, 1, 1), Vector3.new(2, 2, 2), Vector3.new(3, 3, 3))
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
07 May 2014 02:25 AM
Use select for tuples! :P

local function Random(...)
return (select(math.random(select("#",...)),...))
end
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