How can I tween this billboard GUI?

function Base.UpdateHealth(damage)
	if damage then
		Base.CurrentHealth -= damage
	end
	local info = TweenInfo.new(
		3, 
		Enum.EasingStyle.Circular, 
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	
	local gui = Base.Model.HealthGui
	local percent = Base.CurrentHealth / Base.MaxHealth
	
	tweenService:Create(gui.CurrentHealth, info{Size = UDim2.new(percent,0, 0.5,0)}) 
	
	if Base.CurrentHealth <= 0 then
		GameOverEvent:Fire()
		gui.HealthPercent.Text = 0 .. "/" .. Base.MaxHealth
	else
		gui.HealthPercent.Text = Base.CurrentHealth .. "/" .. Base.MaxHealth
	end
	
end

Hello! Im trying to play a tween on a billboard GUI is there a way that I can achieve that? the code is inside the module script. The code runs without errors but it doesn’t play the tween. Is it not possible to play a tween inside a module script?

2 Likes

im not sure you can tween a billboardGui,
maybe create a for loop that offsets the StudOffset Parameter on the BillBoardGui or use the gui functions

GuiInstance:TweenSize(EndUdim2,direction,style,duration)

also try setting the Easing Direction on your tween to InOut in case that is causing any issues!

1 Like
function Base.UpdateHealth(damage)
	if damage then
		Base.CurrentHealth -= damage
	end
	local info = TweenInfo.new(
		3, 
		Enum.EasingStyle.Circular, 
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
	
	local gui = Base.Model.HealthGui
	local percent = Base.CurrentHealth / Base.MaxHealth
	
	gui.CurrentHealth:TweenSize((UDim2.new(percent,0,0.5,0)),InOut,Sine,2)
	--tweenService:Create(gui.CurrentHealth, info, {Size = UDim2.new(percent,0, 0.5,0)}) 
	--gui.CurrentHealth.Size = UDim2.new(percent, 0, 0.5,0)
	if Base.CurrentHealth <= 0 then
		GameOverEvent:Fire()
		gui.HealthPercent.Text = 0 .. "/" .. Base.MaxHealth
	else
		gui.HealthPercent.Text = Base.CurrentHealth .. "/" .. Base.MaxHealth
	end
	
end


Is this correct?


Yowww It actually worked man you are actually Insane!! Thanks again!!

haha, we meet again, no problem! have a good time developing :slight_smile:

1 Like


Yo sorry man…I’ve ran into another problem, The texlabel doesn’t show the health value when I first run the program. The value only changes when enemies start to pass through

do you update the gui when you are spawning the Enemy?

local Base = require(script.Base)
local SpawnModule = require(script.SpawnModule)
local UnitSpawnModule = require(script.UnitSpawnModule)


local serverStorage = game:GetService("ServerStorage")
local bindables = serverStorage:WaitForChild("Bindables")
local RepStorage = game:GetService("ReplicatedStorage")

local RemoteEvents = RepStorage:WaitForChild("Events")
local GameOverEvent = bindables:WaitForChild("GameOver")
local GameOverevnt =  RemoteEvents:WaitForChild("GameOver")

local map = workspace.Map1

Base.Setup(map, 150)
local GameOver = false


GameOverEvent.Event:Connect(function()
	GameOver = true
end)




GameOverevnt.OnServerEvent:Connect(function()
	GameOver = true
end)

GameOverEvent.Event:Connect(function()
	GameOver = true
end)

for wave = 1, 10 do
	print("Wave Startingg: "..wave)
	
	if wave < 6 then
		SpawnModule.Spawn("Rat", map, (4 * wave), 1.2, 4)
		SpawnModule.Spawn("ChillGuy", map, (4 * wave), 1.2, 4)
	
	elseif wave < 10 then
		
		SpawnModule.Spawn("ChillGuy",map, (3 * wave), 0.7,1)
	
		
	elseif wave == 10 then
		
		SpawnModule.Spawn("ChillGuy",map, 50, 0.7, 1)
		
	
	end
	
	
	
	repeat 
		task.wait(1)
		
	until #workspace.Mobs:GetChildren() == 0 or GameOver
	
	if GameOver then
		print("GAME OVER")
		break
	end
	print("WAVE ENDED")
	task.wait(1)
end

I set it up here on the main script

image
Yoo never mindd, I actually forgot to call the function on the Base.Setup T_T. Anywayss Thankss again man!! you are a geniuss

no problem, glad you could get it working lol :smile:

1 Like

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