Billboard UI disappears for some reason

recently i encountered a bug in my game while i was working on my stamina gui
everytime the stamina ui reaches a certain y offset it just disappears for now reason
robloxapp-20240701-1812137.wmv (1.0 MB)
(sorry for low quality)
i dont think it has anything to do with the script but here is it anyway

local player = game:GetService("Players").LocalPlayer
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local activetool = false
local A = require(game:GetService("ReplicatedStorage").Assets.Module.Assets)
----------------------------------------
local uis = game:GetService("UserInputService")
local cas = game:GetService("ContextActionService")
local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")
-------------
local Stamina = 100
local StaminaCap = Stamina
local DrainStamina = .05
local IsRunning
local Rspeed = 25
local Nspeed = 16
local IsWalking
local RFOV = 73
local NFOV = 70
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local Info2 = TweenInfo.new(.7, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local FOVchange = ts:Create(game.Workspace.CurrentCamera,Info,{FieldOfView = RFOV})
local FOVdef = ts:Create(game.Workspace.CurrentCamera,Info,{FieldOfView = NFOV})
local rt = ts:Create(humanoid,Info2,{WalkSpeed = Rspeed})
local wt = ts:Create(humanoid,Info2,{WalkSpeed = Nspeed})
local lastTime = tick()
local maxTick = 1
-------------
local anim = game:GetService("ReplicatedStorage").Assets.Animations.Run
local runanim = humanoid:LoadAnimation(anim)
-------------
local Torso = game.Players.LocalPlayer.Character:WaitForChild("Torso")
local StaminaUI = A.StaminaUI:Clone();StaminaUI.Parent = Torso
local Holder = StaminaUI.Holder
local Bar = Holder.Bar
-------------
A.ToolActive.OnClientEvent:Connect(function()
	if activetool == false then
		activetool = true
		wait(1)
		activetool = false
	end
end)


humanoid.AutoRotate = true

local function StopRun()
	runanim:Stop()
	IsRunning = false
	wt:Play()
	FOVdef:Play()
end

local function PlayRun()
	runanim:Play()
	IsRunning = true
	rt:Play()
	FOVchange:Play()
end

rs.Heartbeat:Connect(function()
	Bar.Size = UDim2.new(0,23,0,Stamina*2.51)
	if IsRunning == true then
		Stamina = Stamina - DrainStamina
	elseif IsRunning == false and Stamina < StaminaCap then
		Stamina = Stamina + DrainStamina
	end
	if Stamina <= 0 then
		StopRun()
	end
end)

humanoid.Running:connect(function(Speed)
	if Speed == Rspeed and IsRunning and not runanim.IsPlaying then
		PlayRun()
	elseif Speed == Rspeed and not IsRunning and runanim.IsPlaying or Speed == Nspeed and runanim.IsPlaying or  Stamina == 0 or  workspace.CurrentCamera.FieldOfView > NFOV and not IsRunning then
		StopRun()
	elseif Speed == Rspeed and runanim.IsPlaying and activetool == true or runanim.IsPlaying and activetool == true then
		StopRun()
	end
end)

humanoid.Changed:Connect(function()
	if runanim.IsPlaying and humanoid.Jump then
		StopRun()
	end
end)

uis.InputBegan:Connect(function(input, gameprocessed)
	if not gameprocessed then
		if input.KeyCode == Enum.KeyCode.W and not activetool then
			if tick() - lastTime <= 1 then
				PlayRun()
			else
				lastTime = tick()
			end
		end
	end
end)

uis.InputEnded:Connect(function(input, gameprocessed)
	if not gameprocessed then
		if IsRunning and input.KeyCode == Enum.KeyCode.W then
			StopRun()
		end
	end
end)

(line 63 - 73)

Hello, I suggest using more incremental values instead of doing Stamina * 2.51 when you’re setting the size of Bar on line 63. This will require you to go from offset to scale, though. As long as your bar (the blue bar) is inside a frame, such as the white one in the video you have sent, this transition should be no issue. That way, you can simply do this:

Bar.Size = UDim2.new(1, 0, Stamina / StaminaCap, 0)

I hope you find this helpful, let me know if there’s questions.

robloxapp-20240701-1918435.wmv (669.0 KB)
it still doesnt work
(thank you for the suggestion tho)

From what I’ve tested, this isn’t an issue with the script, it’s the billboardGui. Try make the BillboardGui size {0, 25},{0, 100} and the holder size {1, 0},{1, 0}.
https://gyazo.com/3b2360bc08ce3267e5a83ce9378c5359.mp4

1 Like

ty this works now but… it looks too small, is there any other way i can make this work but not make the gui too small?

Yes, you can adjust the size of the BillboardGui to whatever you like. The sizes I provided were just examples. Just make sure that the content inside doesn’t stretch outside the BillboardGui’s bounds if you increase the size.

If you’re unsure how to adjust coordinates, here are some examples you can tweak:

  1. Large: {0, 150},{0, 450}
  2. Medium: {0, 100},{0, 300}
  3. Small: {0, 50},{0, 150}

ty i rly appreciate your help

char limit

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