A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeFAQRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
 
naknak
 
Supernapalm
 
m27frogy
 
slayer9365
 
myrco919
 
branefreez
 
ninga95
 
CloneTrooper787
 
raboy117
 
Top posting users this month
Latest topics
» Send me an Email
January 8th 2016, 10:14 am by naknak

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
July 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
July 6th 2015, 4:16 pm by m27frogy

» Ambassador!
April 15th 2015, 11:40 pm by naknak

» Boop - Tag
April 13th 2015, 9:46 pm by naknak

» Vip Class Script
April 13th 2015, 4:54 pm by naknak

» Who's active?!
April 13th 2015, 4:52 pm by naknak

» Where to go from here.
April 13th 2015, 4:51 pm by naknak

» Genesis Point
July 17th 2014, 7:04 pm by branefreez

» Reward System
July 17th 2014, 5:41 am by m27frogy

» Script Request
July 10th 2014, 11:43 am by naknak

» local scripts?
July 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
July 10th 2014, 11:36 am by naknak

» Hi. I am new here
April 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
January 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
January 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
January 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
November 26th 2013, 3:33 pm by Keanu73

» Improve Coding
October 26th 2013, 1:12 pm by pook03

» Simple Button
September 1st 2013, 6:19 pm by branefreez


Share | 
 

 The Vector3.new() Function (and more)

View previous topic View next topic Go down 
AuthorMessage
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: The Vector3.new() Function (and more)   January 18th 2011, 11:40 pm

Dedicate to the one's who have no clue about scripting whatsoever

Vector3.new() is a function. Functions in Lua are things that you use to edit something. This tutorial explains how to use Vector3.new.

Vector3.new() has many uses in ROBLOX. It can be used for Position, Size, Velocity, Force, and many more things.

Let's start with the basics. To use Vector3.new(), you must put something, anything, inside the parenthesis. Note that not all functions require this, but this function must edit 3 values, each standing for 3 dimensions. So in reality, its Vector3.new(%x, y, z%).

For example. If you want to change your Position, this is not the way to go:

Code:
game.Workspace.%Player%.Torso.Position = 0,100,0[/strike] --[[change %Player% into your name--]]

You must do this:

Code:
game.Workspace.%Player%.Torso.Position =  Vector3.new(0,100,0)

Hooray! You learned how to use Vector3.new(x,y,z)! Now. Let's take this deeper.

If you were to do something like this...

Code:
game.Workspace.%Player%.Torso.Position = Vector3.new(%x, z%)

... you would get x, y, not x, z right? You want to just change your x and z dimensions. To fix this you do this:

Code:
[[game.Workspace.%Player%.Torso.Position = game.Workspace.%Player%.Torso.Position + Vector3.new(%x%, 0, %z%)]] --[[ i just use brackets for multi-line stuff --]]

There's another thing I wan't to go over. If you add math.random(%x, y%) into play, you can have more power than you can ever imagine. math.random(%x, y%) is an important function, of course, for random numbers. Now you can make your dimensions go wild!

Also the Instance.new("%String%) function is good to use. With this function you can create many object players use to build things on ROBLOX.

while true do simply means make an infinite loop. To execute the loop, you must end the loop with end. This can only be broken with the function break(), but let's not get to technical here.

Let's use Velocity this time.

Code:
while true do
    local vel = Instance.new("BodyVelocity")
    [[vel.Velocity = Vector3.new(math.random(1,100), math.random(1,100),
    math.random(1,100))]]
    vel.Parent = workspace.%Player%.Torso --[[ workspace is shortcut for
    game.Workspace]]
    wait(5)
end

This is the end of the tutorial. Have fun!

PM me if you found a mistake in this.


Last edited by Supernapalm on January 24th 2011, 9:30 pm; edited 1 time in total
Back to top Go down
http://hackthissite.org
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 18th 2011, 11:41 pm

hmmm... this looks pretty good
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: The Vector3.new() Function (and more)   January 19th 2011, 6:46 am

not bad

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
naknak
Administrator
Administrator
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: The Vector3.new() Function (and more)   January 19th 2011, 8:03 pm

Lengthy, nice.
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 19th 2011, 8:50 pm

thx, but i just thought about adding wait(10) in the while true do loop
Back to top Go down
http://hackthissite.org
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 19th 2011, 8:50 pm

nah, it would be too complicated for beginners.
Back to top Go down
http://hackthissite.org
naknak
Administrator
Administrator
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: The Vector3.new() Function (and more)   January 19th 2011, 9:54 pm

Code:
while wait(10) do

I always use that
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 19th 2011, 10:24 pm

nice
Back to top Go down
http://hackthissite.org
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 19th 2011, 10:31 pm


how does it work, though? does wait() return true when it is executed, and return false when the function is completed? that's what im thinking
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: The Vector3.new() Function (and more)   January 20th 2011, 6:29 pm

I dunno. O.o

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
naknak
Administrator
Administrator
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: The Vector3.new() Function (and more)   January 20th 2011, 7:11 pm

wait() always returns true
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 20th 2011, 9:04 pm

oh. nvm. i was thinking something else.
Back to top Go down
http://hackthissite.org
myrco919
Intermediate Scripter
Intermediate Scripter
avatar

Posts : 190
Join date : 2011-01-21
Age : 19
Location : Holland

PostSubject: Re: The Vector3.new() Function (and more)   January 24th 2011, 9:48 am

v.Position = (((p.Position + v.Position)/2) + p.Position ^ 2)

:33
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 24th 2011, 8:24 pm

what are you talking about?
Back to top Go down
http://hackthissite.org
CloneTrooper787
Moderator
Moderator
avatar

Posts : 81
Join date : 2011-01-22

PostSubject: Re: The Vector3.new() Function (and more)   January 25th 2011, 10:10 pm

@naknak- while true do
wait(10) --seems more formal to me than while wait(10) do

_________________
CloneTrooper787, Site Moderator
Back to top Go down
naknak
Administrator
Administrator
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: The Vector3.new() Function (and more)   January 25th 2011, 10:12 pm

while wait(10) do -- more convienent for people who have to encrypt there code (like me)


Size matters. The smaller it is, the easier it is to encrypt. But I am the only one who ever encrypts, so bleh.
Back to top Go down
CloneTrooper787
Moderator
Moderator
avatar

Posts : 81
Join date : 2011-01-22

PostSubject: Re: The Vector3.new() Function (and more)   January 25th 2011, 10:38 pm

Note to self: Size matters; Smaller is easier...

_________________
CloneTrooper787, Site Moderator
Back to top Go down
naknak
Administrator
Administrator
avatar

Posts : 878
Join date : 2010-07-30

PostSubject: Re: The Vector3.new() Function (and more)   January 25th 2011, 10:39 pm

Smaller is easier IF you can handle it ;)
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 25th 2011, 11:43 pm

but the disadvantage is that you must wait10) first. maybe this is what you want, maybe not.
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: The Vector3.new() Function (and more)   January 26th 2011, 10:14 am

if u wanna encrypt something then don't use white spaces. And make the function names shorter:

p=print
p("hi")

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: The Vector3.new() Function (and more)   January 26th 2011, 10:16 am

I made an encrypted that can encrypt over 2000000 characters without crashing! I tested it with a 272k long line script! :P

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Supernapalm
Expert Scripter
Expert Scripter


Posts : 393
Join date : 2011-01-17

PostSubject: Re: The Vector3.new() Function (and more)   January 27th 2011, 9:37 pm

how do you encrypt your script with lua?
Back to top Go down
http://hackthissite.org
blueymaddog
Administrator
Administrator
avatar

Posts : 1081
Join date : 2010-12-09
Age : 19

PostSubject: Re: The Vector3.new() Function (and more)   February 8th 2012, 4:59 am

one way is :byte()

_________________
blueymaddog
Administrator • Moderator • Expert Scripter
PM: blueymaddog
<+1 post. ujelly?>
Back to top Go down
Sponsored content




PostSubject: Re: The Vector3.new() Function (and more)   

Back to top Go down
 
The Vector3.new() Function (and more)
View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Tutorials and Resources :: Beginner-
Jump to: