How do I make a part change size only from one face?

So i have a sled/part where I clone a part and weld it to that part, when player collects snow i want that part to go up, but it also does so from the bottom.

How do i make it only go up from the top face?

local TweenService = game:GetService("TweenService")

local sledEvent = game.ReplicatedStorage:WaitForChild("sledLocalEvent")

sledEvent.OnServerEvent:Connect(function(plr)
	local playerFolder = plr:WaitForChild("playerFolder")
	local leaderstats = plr:WaitForChild("leaderstats")
	local playerSledFolder = plr.Character:WaitForChild("sledFolder")
	local playerSled = playerSledFolder:WaitForChild("SledPart")

	local maxCapacity = playerFolder.sledMaxCapacity.Value
	local maxHeight = 20
	local snowVisual = playerSledFolder:WaitForChild("SnowVisual")

	local currentSnow = leaderstats.Snow.Value
	local heightProportion = currentSnow / maxCapacity
	local newYHeight = maxHeight * heightProportion

	newYHeight = math.clamp(newYHeight, 0, maxHeight)

	local originalTopPosition = snowVisual.Position + Vector3.new(0, snowVisual.Size.y / 2, 0)

	snowVisual.Size = Vector3.new(snowVisual.Size.X, newYHeight, snowVisual.Size.Z)

	local newTopPosition = snowVisual.Position + Vector3.new(0, snowVisual.Size.y / 2, 0)

	snowVisual.CFrame = snowVisual.CFrame * CFrame.new(originalTopPosition - newTopPosition)

	playerSled.Billboard.Text.Text = currentSnow .. "/" .. maxCapacity .. "☃️"
end)

When Increasing the Size, it will apply the size, but keep the Objects Position in place, from this point, it will be at the very center of the object, which other words separates the top half. And bottom half into two.

When changing size, all you have to do is add to the position by saying newSize/2, depending on its axis.
Negative if you are moving down, but Positive if you are moving up.

Note: you cant make changes on an objects size from one face, only its size on all faces, in which you have to account for its current position.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.