Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

3 comments

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

0

I dont think this will work because a part size comes in vector3. Note

0

Try mah answer

4 answers

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!

3 comments

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.

0

I dont think it will work because things such as position/size come in vector3 and vector3 has 3 arguments (x,y,z)

0

so should i use tweenservice?

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.