Health and stamina bar like the game called : criminality

So i’m making a game that has pretty much the same concept as the game criminality and i’m doing pretty good progress but i’m stuck at this :
I wanna make a health gui and stamina bar like this : https://youtu.be/7P6jE1oZ9OE?t=49

as you can see the health bar slides smoothly and there is even a gui that shows parts damaged and the stamina bar is similar to the health bar but it detects when the player is running or jumping etc…

I’ve searched for a long time but didn’t find anything, Could anyone help?
And thanks in advance :grinning_face_with_smiling_eyes:

4 Likes

There some posts around the devforum on how to make those, such as this and this one.

1 Like

Ok i’ll be sure to check them out thx :grinning:

I’ve seen them but how could i make the gui that shows the parts damaged? :thinking:

The method you could use is to insert values like StringValues inside of the damaged parts and them make a while loop with a for loop that goes through the characters part and check if they have the damage value inside of them.

Example:

local player = game.Players.LocalPlayer

while wait(0.5) do
    for i, v in pairs(player.Character:GetDescendants()) do
        if v:IsA("StringValue") and v.Name == "DamageValue" then
            local parent = v.Parent

            --do other stuff here
        end
    end
end
2 Likes

You can insert a Object or String value inside the character, use a ChildAdded event, and then do the ui things.

1 Like

OH , that’s a good idea i’ll see what i can do thx :smiley:

I have another question if you see on the video that i showed you previously both health and body parts gui changes colors like green when it’s good, dark green when it a little bad and red when it’s really bad , and if you go further in the video you notice that :
the part that is damaged like a lot starts flashing so it’s becoming black then red again then black etc…
How can i make both effects?

For a smooth gui color change effect i suggest to use TweenService and use an IntValue so you can set a determinate amount of damage so the script can check if it is up to 0.5 it will be orange, 1 red, etc.

Can you include some code so i can get a better idea of it? or just a post that does that?

local player = game.Players.LocalPlayer

while wait(0.5) do
    for i, v in pairs(player.Character:GetDescendants()) do
        if v:IsA("NumberValue") and v.Name == "DamageValue" then
            if v.Value > 0 and v.Value <= 0.5 then
                --Set color to orange
            elseif v.Value >= 0.6 and v.Value <= 1 then
                --SetColor to red
            end
        end
    end
end

Also use NumberValue so you can set decimal numbers.

3 Likes

Ok thanks i’ll tweak around with the code and see what i can do!

And also how can i set the value when a specific body part was hit?

You can get the value’s parent, find it in a frame, and then tween the color of the ui object. Depends on how your system works.

I think my question wasn’t clear enough :
How to get the value’s parent?

Get the parent property from the value.
v.Parent

Yea but like is there a function that detects if a specific part was hit or…?

Yep, use the 1st argument that was passed through a Touched event.

local Players = game:GetService('Players')

part.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end

print(hit.Name)
end)

you inspired me to post a stamina bar tutorial i will post it

Oh it’s nice to see people like you that shares ressources :grinning: