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

how do I increase the size of a Part to one side only?

Asked by
lytew 99
4 years ago

I created this script to increase the size of a Part, but I wanted it to increase in size only to one side (and not two sides as it normally is) script:

Game.Players.PlayerAdded:Wait()
While true do
wait()
script.Parent.Size = Script.Parent.Size + 1
end

my problem is that it increases, but for two sides and not one

0
First of all, this is a very inefficient way of creating movement. It is much better to use TweenService. And it seems like you will have to reposition it as you scale it Benbebop 1049 — 4y
0
I dont think this will work because a part size comes in vector3. Note JesseSong 3916 — 4y
0
Try mah answer TheRealPotatoChips 793 — 4y

4 answers

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

The size property has three numbers, X Y Z. Here is an example:

script.Parent.Size = script.Parent.Size + Vector3.new(0,1,0)

Now, I don't have your game to know what direction is X, Y or Z, but you can change the numbers between the parenthesis to check what is the direction. I hope this helped!

1
Though this does apply, I think the problem was that it expands both sides of the object on the axis that you want. Where it needs to expand on one side. Benbebop 1049 — 4y
0
I dont think it will work because things such as position/size come in vector3 and vector3 has 3 arguments (x,y,z) JesseSong 3916 — 4y
0
so should i use tweenservice? lytew 99 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

i think using Part:Resize(surface, amount).. learn more here

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I know what you're talking about. Here's the script:

Game.Players.PlayerAdded:Wait()

While true do
    local StartingSize = script.Parent.Size -- Getting the size of the part before the changment of the size
    wait()
    script.Parent.Size = Script.Parent.Size + Vector3.new(0, 1, 0) -- Adding to the size, change it to whatever you want
    local ChangedSize = script.Parent.Size - PartSize -- Getting the difference of the starting size and the new size.

    script.Parent.Position = Vector3.new(ChangedSize / 2) -- Changing the position of the part so we have the impression that it's just changing size on one side
end

So if you just want the part to expand on one side, you have to change the part's position. Also, if you wanna change the size of the part, use Vector3.new (line 6).

At line 8, I divided the difference of the size by 2, because in Roblox, normally, when you change the size of a part, the size will split up equally and add on both directions of the axis.

Example: if you expand a part's size by Vector3.new(0, 1, 0), if will expand on both sides of the Y-axis by 0.5.

Here's the script in clean version:

Game.Players.PlayerAdded:Wait()

While true do
    local StartingSize = script.Parent.Size

    wait()

    script.Parent.Size = Script.Parent.Size + Vector3.new(0, 1, 0)

    local ChangedSize = script.Parent.Size - PartSize

    script.Parent.Position = Vector3.new(ChangedSize / 2)
end

Hope this helped!

I'm sure it will work, try it.

Log in to vote
-1
Answered by 4 years ago

Hey there, if you need to do it ONLY by a script, then i dont know. But if you need to do it with the scale tool, then i recommend you to use the F3X Building Tools, since it works for me.

Get them there:

https://www.roblox.com/library/144950355/Building-Tools-by-F3X-Plugin

Answer this question