Why is the scale not working correctly (UDim2)?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I need the scale to work, for example, as a player’s health scale.

  2. What is the issue? Include screenshots / videos if possible!
    The scale does not work correctly, it shifts to the left, although I did not ask it to. And it still needs to be reduced on the one hand.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Not sure where it’s going…
    bar

local ScaleFrame = script.Parent.ScaleFrame

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(.3, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, .3)

local LightZone = game.Workspace.LightZone

local Debounce = false

LightZone.Touched:Connect(function (otherPart)
	if otherPart and not Debounce then
		Debounce = true
		TweenService:Create(ScaleFrame, tweenInfo, {Size = UDim2.new(0,ScaleFrame.Size.X.Offset - 50,0,ScaleFrame.Size.Y.Offset)}):Play()
		task.wait(.3)
		Debounce = false
	end
end)

When tweening Health bar, using Scale value instead of offset value is much better. In this case, since your bar is vertical, you would want to tween in Y-axis (up and down) you can leave X-axis how it is.

I noticed that in the vertical position it changes not only the size but also the position, so I made it horizontal

If you want to tween only its side, you can use TweenSize instead.

1 Like

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