Roblox why can't you just add tweening in only direction like position, but for size it's irritating

drinkPart isn’t a union. U can try to test my script if u want here’s the RBX file

1 Like

test.rbxl (963.8 KB)

It’s the drink machines in the back btw. the 3 drink machines on a counter I’m not tweening the size, just tweening the position since I was irritated, so that’s why it works but if the player just looks through the counter it’ll look weird or unreleastic that’s why I’d rather size it

fill drink test
task.wait(4) --so you can see it

--a cylinder; orientation 0,0,-90 size 0.15,1,1
local part = workspace:WaitForChild("Drink")
local ts = game:GetService("TweenService")

--0.15 grows in place to 0.85
--part.Transparency = 0

local dx = (0.85 - 0.15) / 2
local goal = {Size = Vector3.new(0.85, 1, 1),
	Position = part.Position - part.CFrame.XVector * dx
} ts:Create(part, TweenInfo.new(1), goal):Play()

--drawback, it needs to be anchored
2 Likes

You need to tween the position at the same time. To get the perfect tween, the calculs are the following:

  • When the goal size is higher than the part’s current Y size
    (goal size - part current Y size) / 2
    (0.9 - Part.Size.Y) / 2 >>> (0.9 - 0.1) / 2

  • When the goal size is lower than the part’s current Y size
    (part current Y size - goal size) / 2
    (Part.Size.Y - 0.9) / 2 >>> (1.5 - 0.9) / 2

Now if you are looking to change the resize direction (from bottom to top > from top to bottom), you only need to switch the + to - in the goal position:

  • Part.Position.Y + NewPos >>> Part.Position.Y - NewPos.

local NewPos = (0.9 - Part.Size.Y) / 2
local TweenGoal = {
	Size = Vector3.new(Part.Size.X, 0.9, Part.Size.Z),
	Position = Vector3.new(Part.Position.X, Part.Position.Y + NewPos, Part.Position.Z),
}

The objective is simply to tween the position by half the size difference.
For exemple, if the part size is 0.1 and you want to tween it to 0.9, then the size difference is 0.8.
So you are going to tween the position by 0.8 divided by half, which is equal to 0.4.

Feel free to ask questions if it is confusing.

literally just this…

1 Like

… what else is it supposed to do? Magically know what direction you want it to resize in?

Just tween the size & position at the same time. Or use BasePart:Resize().

You don’t want roblox to turn itself into a TV remote bro.
If you cant devide value by 2 (better multiply it by 0.5 intsead C programming ahh tips :money_mouth_face: ) then its pretty much your fault…

1 Like

test2.rbxl (1.1 MB)

my other machines

You have been given the solution multiple times, can you mark @doomguy2164 post as the solution?

Imagine you scale a part up by 1 unit on the x-axis. You want it to only move in one direction. So how much do we need to move the part so that it stays flush? The parts scale equally in both directions, so logically you would have to move it by 0.5 in the direction you need on the x-axis.

This is your solution, if it is not working, you should try to disable any constraints on the part while tweening

Edit: I am qualified to say it is in fact your solution because I have coded every BTools function from scratch before, where I used this same technique for rescaling in a single direction like the Studio resize tool.

1 Like

You’ve already been given the answer several times here, but here is the exact same answer but explained in beyond too much detail.


When tweening a part’s size, it’ll scale itself around its origin point (the center of the part’s overall circumference)
This is of course pretty bad if you want to make it look like the part is scaling upwards.

So, how do you actually make it look like the glass is filling with water? It’s pretty simple!

In a single Tween, instead of just altering the scale, you alter the position, too!

Here is a code sample:

function fillGlass(liquidPart)
	local goalSize = 2
	game:GetService("TweenService"):Create(liquidPart, TweenInfo.new(
		3,
		Enum.EasingStyle.Linear),
		{
			["Size"] = liquidPart.Size + Vector3.new(goalSize, 0, 0), --// Change the axis depending what your model requires
			["Position"] = liquidPart.Position + Vector3.new(0, goalSize / 2, 0)
		}
	):Play()
end

--// example use of function:
fillGlass(cup.Liquid) --// Cup is the base part, and the liquid is a child.


image
(liquid isn’t anchored, Union is, however Union can be welded, too)

To sum it up:
When scaling parts, they’ll only scale around their center. To fix this, all you have to do is add half the scale value to the position on the relevant axis (in this case, the Y axis)

1 Like

I noticed they don’t work because my liquid has a orientation of 0,0,90 and when I try to scale it, it sets the orientation back to 0,0,0 which is sideways

qwdqwdqwd
It keeps going out of the cup, why is it an offset, it works but its floating from the cup like seriously? I set the orientation to 0,0,90 and its doing this!

Can you explain what’s going on because this literally makes no sense, I understand I resized a part with f3x in studio and noticed the position moves. Now why the hell is it turning sideways, or floating out of the cup like I swear.

wef.rbxl (1.1 MB)