Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a part shrink and grow?

Asked by 7 years ago

if i wanted to make a part grow and script would i do this

Size.Part = Size(#,#,#)

if not please fix

3 answers

Log in to vote
3
Answered by 7 years ago

+1 for being a girl programmer! The world needs more of them.. they're so hard to come across.

Also, to make a part grow and shrink you would need to do something similar to what you've posted.

Part.Size = Vector3.new(#,#,#)

For starters, your script is wrong because you are trying to get the property "Part" from "Size". That's not how it really works. Think of parents as a tree of stuff. For example, a tool. Say you have a gun. The gun itself is a tool. Inside the tool is a model. Inside the model is a set of parts which give the gun its actual shape. The tree would go like this.

Tool --> Model --> Part1, Part2, Part3

If you wanted to access one of the parts, you would have to format your code like so.

Tool.Model.Part1

The Tool is the parent of Model, and Model is the parent of the Parts

I hope that clears it up. Now to properties.

Each part has its own properties. These properties can include position, transparency, reflectance, and for your case, size. Properties, in short, are essentially what the object is like. Every object in the studio has their own properties. I just listed some of the properties unique to the Part object.

To adjust these properties, you would have to approach them in somewhat different ways.

If you wanted to change the VALUE of a property, you would do something like this. (I am referring back to the gun example)

Tool.Model.Part1.Transparency = 1

This particular line of code would make the part1 invisible. (1 being full transparency, 0 being no transparency.)

How do you know if you can change the value of a property? Simply put, there will be a box in the properties menu where you can adjust the number of the property.

Some values will require 3 inputs, such as SIZE or POSITION. This is where Vector3 kicks in. Before I go over this, I'm giving you a link to the ROBLOX wiki, a very useful website that ROBLOX runs. http://wiki.roblox.com/index.php?title=Special:RobloxLandingPage Here's a page that talks all about Vector3. http://wiki.roblox.com/index.php?title=Vector3

Also, I see a lot of new programmers having trouble locating stuff. So here's a picture of my studio. It has all the essentials you will need to develop things properly. If you want to add some of these things that you don't have, look in the "View" menu and enable everything you see in the picture below.

http://prntscr.com/cuu2dl

Now with that aside, let's talk about your size script.

SIZE uses Vector3 because it has 3 values, X Y and Z. These are axis values, and can be adjusted accordingly. You don't need to know much about them, but essentially X is length, Y is height, and Z is width. X and Z are very similar but are different for a reason that would be kind of hard to explain to you. As you can probably guess, The format of Vector3 utilizes the XYZ axies. Like so. Vector3(X,Y,Z)

Your final script, therefore, would look like this.

Part.Size = Vector3.new(X,Y,Z)

However, this actually isn't the final script...

You say you want to utilize this to make a block grow bigger and shrink.

Well, for that, you will need to learn loops.

Take a good look through this ROBLOX wiki page. http://wiki.roblox.com/index.php?title=Loops

There are three types of loops. While, For, and Repeat.

In this case, we'll be using a for loop.

I will give you the code below and I will explain to you what it does afterward.

for i = 1, 10, 1 do
--code here
end

This for loop will loop through the code inside of it from 1 to 10, in increments of 1. Therefore, it will loop a total of 10 times. the i isn't very important to know for beginners , but let's just use it for this next portion of code.

for i = 1,10,1 do Part.Size = Part.Size * Vector3.new(0,i,0) end

This new line of code looks very tricky, I know. But I'll explain.

Part.Size = Part.Size * Vector3.new(0,i,0)

So if you recall i from earlier, it loops from 1 to 10 in increments of 1. i is essentially how far the loop has gone. If its looped once, i = 1. twice, i = 2. This is only because our increment is set to 1. It goes on UNTIL i reaches 10. Then the loop stops completely.

We are utilizing this to change the size of the part. In this case, we're changing the size of the Y axis. The part will become taller.

To sum up the new line of code... Part.Size is EQUAL to ITSELF PLUS a new Vector3 that adjusts the Y axis using the i from the for loop.

Why plus? Don't let the * trick you. It actually is ADDING the new Vector3 to the current size. So if the Y for the current size is set to 2, then it would add i to it (which is what the loop is currently at). So if the loop is currently on loop 5, the i would be set to 5. Therefore, 5 would be added to the part's Y size. The new size of the Y would be 7.

It'll make sense with more practice. But here is your final chunk of code.

for i = 1,10,1 do
Part.Size = Part.Size * Vector3.new(0,i,0)
end

If you want to change the total Y to not be adding 10 to your current Y, then change the 10 to whatever you want it to be. And if you want the Y axis to not be the only thing adjusted, then you can set the "i" as the 0 values in the new Vector if you choose. The 0's are place holders, and they are meant to do nothing, as adding 0 to the X,Y, or Z value will do nothing. Basic math right there.

One more thing. You also mentioned you want the part to shrink back down. Similar way of doing it. However, instead of going from 1 to 10, you will be going from -1 to -10.

for i = -1,-10,-1 do
Part.Size = Part.Size * Vector3.new(0,i,0)
end

I HOPE THIS HELPPSSSS

ALSO, SCRIPTING HELPERS IS NOT A REQUEST SIITEEEEEE ALWAYS REMEMBER THAT (...we would also prefer you to put some more effort into your code. good try anyways.)

Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
while true do
wait(1)
part.Size = Vector3.new(2,2,2)
wait(1)
part.Size = Vector3.new(1,1,1)
end

The part will shrink and grow infinitely. You get the idea.

Log in to vote
0
Answered by
lyxture 27
7 years ago

first you need to find your Part if it is in the workspace then you need to write this you always begin with game so

game.Workspace.Part.Size = Vector3.new(1,1,1)

if you want it to become +1 bigger from xyz angles then you need to fill it in like so

game.Workspace.Part.Size = game.Workspace.Part.Size + Vector3.new(1,1,1)

Answer this question