GUI tweens are playing instantly [Solved]

I am trying to recreate that effect that many games have that when you take damage the green healthbar will go down and there will be a red healthbar that goes down afterwards. I am tweening the red healthbar but it is making it move instantly instead of actually tweening. Here is the healthbar :

Here is the script that gets fired every time the player takes damage. The event sends over the players current HP , max Hp and if it is an increase or decrease in HP :

local HealthGui = PlayerGUI:WaitForChild("healthGUI")
local GreenBar = HealthGui.HPframe.HealthDisplay
local RedBar = HealthGui.HPframe.SecondaryHealthDisplay
local HealthEvent = game.ReplicatedStorage["RemoteEvents(s->c)"].HealthEvent
local TweenService = game:GetService("TweenService")

	local BarSize = HP/Max
	if Increase then
		GreenBar.Size =,0,1,0)
		RedBar.Size= GreenBar.Size
		GreenBar.Size =,0,1,0)
		local info =
		local Goals  = {
			Size =,0,1,0)
		local track = TweenService:Create(RedBar,info,Goals)

Also I have tried using tweenservice and UI:TweenSize() but both have the same problem.

try adding a task.wait(1) to test before the track plays

1 Like

I removed the line

RedBar.Size = GreenBar.Size

This fixed it somehow but the problem now is that if the player heals the red bar will not start in the same position as the green bar, which was the whole point of that line.

Edit: I don’t understand this because the red bar’s size is set BEFORE the green bar is shrunk so it shouldn’t cause it to instantly become the same size as the green.

Found the problem, the remote event was sending the wrong signals.

1 Like

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