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: Position = Vector3.new(...)

Previous Thread :: Next Thread 
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
09 Sep 2012 05:20 PM
Okay so I want to not how to make the position random, but with a specified range.

local a = Instance.new("Part", Workspace)
a.Position = Vector3.new(...)

Or if you like using CFrame better you use CFrame. Any help appreciated.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
09 Sep 2012 05:20 PM
*I want to know *within a
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
09 Sep 2012 05:24 PM
local a = Instance.new("Part", Workspace)
a.Position = Vector3.new(math.random(-DistanceRange, +DistanceRange), math.random(-DistanceRange, +DistanceRange), math.random(-DistanceRange, +DistanceRange))

(- and + mean the ends of the spectrum, you dont need the +)
Will make a brick within a radius of DistanceRange
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
09 Sep 2012 05:26 PM
Lol, right before you posted I figured it out, but thanks!

Just to make sure, is there a more efficient way fore my script?

while wait(2) do
local a = Instance.new("Part", Workspace)
a.Position = Vector3.new(math.random(1,50), math.random(10,15), math.random(1,50))
end
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
09 Sep 2012 05:34 PM
while wait(2) do
Instance.new("Part", Workspace).Position = Vector3.new(math.random(1,50), math.random(10,15), math.random(1,50))
end

Other than that, no.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
09 Sep 2012 05:36 PM
Okay thanks!
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
09 Sep 2012 05:36 PM
No problem.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
09 Sep 2012 05:39 PM
Localize your function fetches to make it the most efficient script you can. Instead of Instance.new and math.random all of the time in each loop, cache the functions.

local Inew = Instance.new
local ran = math.random

-- Loop
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
09 Sep 2012 05:41 PM
but the amount of time saved by doing this would be minimal, wouldn't it? computers are very fast these days. i once heard most modern computers can perform a billion operations per second.

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
09 Sep 2012 05:46 PM
Thanks!
Just to clarify, to use CFrame, just in case I wanted them inside each other instead of stacking, would it be like this;

Part.CFrame = CFrame.new(Numbers)
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