You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want it to retract downwards, not upwards.
-
What is the issue? I am reworking the stamina indicator for my climbing system, and I noticed that however I tween it, it sticks to the top when I retract its size.
-
What solutions have you tried so far? I looked for solutions on youtube, the developer forum, the documentation.
I have included the entire climb system, which includes the previous stamina system.
ClimbController.rbxm (14.4 KB)
The problem is located inside of the barmanager script, which is located in fill (There is two atm, the one that is important is inside of a canvasgroup, as I am trying to get this script to work before modifying the main climb controller for optimization, so I have some filler instances that are just there to hold values.)
This is the main tween code for those who do not want to download the RBXL.
local TweenService = game:GetService("TweenService")
local val = script.Parent.Parent.Parent.Fill.Value
local indicator = script.Parent
-- Set the anchor point to the top-center (0.5, 0), so the top stays fixed and the bottom moves down
indicator.AnchorPoint = Vector2.new(0.5, 0)
indicator.Position = UDim2.new(0.5, 0, 0, 0) -- Always anchored at the top
local function tweenStamina(newValue)
local newSizeY = newValue / 100 -- Convert to scale (assuming value is between 0 and 100)
-- Tween the size and keep the top anchored
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local targetSize = UDim2.new(1, 0, newSizeY, 0) -- Shrinking vertically
local tween = TweenService:Create(indicator, tweenInfo, {Size = targetSize})
tween:Play()
end
val.Changed:Connect(function()
tweenStamina(val.Value)
end)