Stamina system is working but when i try to implement it into a bar

I made a sprint system with stamina and i’m trying to implement a stamina bar but it doesn’t work. It doesn’t output any errors.

The local script:

local frame = script.Parent

local bar = frame:WaitForChild("Bar")
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local stamina = char:WaitForChild("Stamina")

local rs = game:GetService("RunService")

stamina.Changed:Connect(function()
	bar.Size = UDim2.new(stamina.Value /100, 0, 1, 0)
end)

take a look at this

  1. Did the “Stamina” Value is in the Character? if it not it will be inf yelid
    2.You Should Have
bar.Size = UDim2.new(stamina.Value /100, 0, 1, 0)

to make the bar display stamina when player spawn

3.Make sure your gui have correct properties
4.the 100 should be player max stamina

Yes, the stamina value is in the character and the bar is displayed, and the max stamina is 100

so what happen when you sprint? the bar dissapear? try look at the bar size when you sprint in player gui

since youre using scale, 1 is the full bar

so maybe

local frame = script.Parent

local bar = frame:WaitForChild("Bar")
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local stamina = char:WaitForChild("Stamina")

local rs = game:GetService("RunService")

stamina.Changed:Connect(function()
	bar.Size = UDim2.new((stamina.Value /100)/100, 0, 1, 0)
end)

i havent tested so tell me what happens and i can tweak the numbers

maybe my brain isnt working right now so dont scream at me if it doesnt work corerectly

The problem is that the bar size doesn’t even change

Nothing happens to the bar, the stamina system works perfectly, so weird.

Bruh, i made it so the bar size will change everytime the stamina decreases or increases instead of changing it everytime you hold shift and it worked.

uis.InputBegan:Connect(function(key, processed)
	if key.KeyCode == Enum.KeyCode.LeftShift then
		if bool.Value == true and running == false and hum.MoveDirection.magnitude > 0 and stamina > 0 then
			running = true
			
			sprint:Play()
			fov:Play()
			while running do
				task.wait(0.075)
				print(stamina)
				bar.Size = UDim2.fromScale(stamina / maxStamina, 1)
				stamina -= 1
				if stamina == 0 then
					tired:Play()
					normal:Play()
					running = false
				end
			end 
		end
	end
end)

uis.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftShift then
		if stamina > 0 then
			running = false
			walk:Play()
			normal:Play()
		else
			running = false
			tired:Play()
			normal:Play()
		end
		task.wait(3)
		while not running and stamina ~= 100 do
			wait(0.01)
			bar.Size = UDim2.fromScale(stamina / maxStamina, 1)
			stamina += 1
		end
	end
end)