ImageLabel tween weird

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 want the stamina and health bar to diminish like they would with a frame as the bar.
  2. What is the issue? Include screenshots / videos if possible!
    It diminishes strangely.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked for solutions on the forum and I couldn’t find anything similar to this.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

this is the part of the script that changes the gui script.Parent.PlayerName.Text = Player.Name
script.Parent.Frame.Frame.PlayerThumb.Image = “rbxthumb://type=AvatarHeadShot&id=” … Player.UserId … “&w=420&h=420”

– Animation ID for running animation
local RunningAnimationId = “rbxassetid://13514845732”

– Load the running animation
local RunAnim = Instance.new(‘Animation’)
RunAnim.AnimationId = RunningAnimationId
local PlayRunAnim = Humanoid:LoadAnimation(RunAnim)

Humanoid:GetPropertyChangedSignal(“Health”):connect(function()
script.Parent.HealthBar.Bar.Size = UDim2.new(math.floor(Humanoid.Health) / 100, 0, 1, 0)
end)

local function UpdateStaminaBar()
script.Parent.StaminaBar.Bar:TweenSize(UDim2.new(Stamina / 100, 0, 1, 0), “Out”, “Linear”, 0)
script.Parent.StaminaBar.Bar.Visible = Stamina > 0
end

local lastSprintTime = tick() – Track the last time sprinting started

Is it because your changing the size of the image, which is not completely square?

It might be, I tried tweening the position of it and moving it to the left into the player icon but its initial position was on the right of my screen when I did that.

This is the code of my attempt:

local TweenService = game:GetService(“TweenService”)

script.Parent.PlayerName.Text = Player.Name
script.Parent.Frame.Frame.PlayerThumb.Image = “rbxthumb://type=AvatarHeadShot&id=” … Player.UserId … “&w=420&h=420”

– Animation ID for running animation
local RunningAnimationId = “rbxassetid://13514845732”

– Load the running animation
local RunAnim = Instance.new(‘Animation’)
RunAnim.AnimationId = RunningAnimationId
local PlayRunAnim = Humanoid:LoadAnimation(RunAnim)

Humanoid:GetPropertyChangedSignal(“Health”):connect(function()
script.Parent.HealthBar.Bar.Size = UDim2.new(math.floor(Humanoid.Health) / 100, 0, 1, 0)
end)

local initialPosition = script.Parent.StaminaBar.Bar.Position

local function UpdateStaminaBar()
local targetPosition = UDim2.new(Stamina / 100, 0, 1, 0) – Calculate the target position of the stamina bar based on the stamina value

local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear) -- Define the tween animation duration and easing style
local tween = TweenService:Create(script.Parent.StaminaBar.Bar, tweenInfo, {Position = initialPosition + targetPosition}) -- Create the tween animation, adding the target position to the initial position

tween:Play() -- Play the tween animation
script.Parent.StaminaBar.Bar.Visible = Stamina > 0

end

local lastSprintTime = tick() – Track the last time sprinting started

This wont work on a normal frame, I would use a scrolling frame instead because that hides the image behind it.
Like this Video

See how its only changing the position and not the size, this is what you need.

1 Like

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