# Godot 4.0 Change Progress bar Fill Color

**URL:** <https://forum.godotengine.org/t/godot-4-0-change-progress-bar-fill-color/627>\
**Category:** Archive\
**Created:** [May 9, 2023, 11:02pm UTC](https://forum.godotengine.org/t/godot-4-0-change-progress-bar-fill-color/627 "2023-05-09T23:02:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://forum.godotengine.org/uploads/default/original/2X/4/4b0a7fa8a6334634b94a13d421f0d99e6f04e21f.svg) [@system](https://forum.godotengine.org/u/system)\
**Post date:** [May 9, 2023, 11:02pm UTC](https://forum.godotengine.org/t/godot-4-0-change-progress-bar-fill-color/627/1 "2023-05-09T23:02:53Z")

</div>

| | | |
| --- | --- | --- |
| ℹ | **Attention** | Topic was automatically imported from the old Question2Answer platform. |
| 👤 | **Asked&nbsp;By** | Venex2004 |

How do I change a progress bar fill bg\_color depending on the user life.

---

<div class="post-metadata">

**Author:** ![system](https://forum.godotengine.org/uploads/default/original/2X/4/4b0a7fa8a6334634b94a13d421f0d99e6f04e21f.svg) [@system](https://forum.godotengine.org/u/system)\
**Post date:** [May 9, 2023, 11:46pm UTC](https://forum.godotengine.org/t/godot-4-0-change-progress-bar-fill-color/627/2 "2023-05-09T23:46:38Z")

</div>

| | | |
| --- | --- | --- |
| 👤 | **Reply From:** | jgodfrey |

Something like this should work:

- Create a new `StyleBoxFlat` object
- Assign it to `ProgressBar` fill style
- Set the color of the stylebox as needed

So, in code:

```auto
func _ready():
	var sb = StyleBoxFlat.new()
	add_theme_stylebox_override("fill", sb)
	sb.bg_color = Color("ff0000")

```

Note, the above script is designed to be attached directly to the `ProgressBar` node. If that’s not your case, you just need a valid reference to it instead…

Once assigned, you can change the color as needed (just using something like that last line of code above).
