TextureProgressBar showing incorrect amount

Godot Version

Godot 4.2.1.stable

Question

My TextureProgressBar isn’t showing the correct amount of “rage” a stat in my game. When I have 100 rage I can superjump, but the bars max is 100 and when it is full I still can’t do the jump.

Edit - 1:
I tested it and it also shows no rage even when I have some. And the bar shows max at 74 rage.

Share the code to see the problem.

extends TextureProgressBar

@export var player: CharacterBody2D

func _ready():
	player.rageChanged.connect(update)
	update()


func update():
	value = player.rage * 100 / player.maxRage


Thats the code for the bar itself, if you need anything else just tell me
you probably need the regen code to:

func _process(delta):
	diff += delta
	if diff >= 0.1:
		rage += 1
		diff = 0
		rageChanged.emit()

I’m warning you that I’m not an expert in this engine, but when you call “connect()” shouldn’t it be “_process(delta)” for the texture to be updated?

I’m not an expert either but I’m pretty sure the connect is to connect the signals, allow the bar to know it needs to update. The bar updates just it doesn’t display correctly

to clamp it to max rage, just use

value=clamp(player.rage*100.0,0,player.maxRage)

I put it in the progressbar script and it says “unidentified identifier in class body”

Edit 1- I put it in the update func and now the bar is always max

so the player.rage doesnt need that 100.0 multiplication
just

value=clamp(player.rage,0.0,player.maxRage)

So I replace the value with that instead of adding it?

Edit- Sorry for asking so many questions also, I’m just really new to coding

yes, change it here:

sorry to inform you but it still shows the wrong amount

show your update code again with modified value with clamp

it should be pretty simple to clamp a value, nothing special with it
either you wrote the update wrong or the player rage never changed

extends TextureProgressBar

@export var player: CharacterBody2D

func _ready():
	player.rageChanged.connect(update)
	update()


func update():
	value=clamp(player.rage,0.0,player.maxRage)

if you add

print(player.rage)

before the clamp, is the rage updating or not?
what the print said?