I’ve seen them but how could i make the gui that shows the parts damaged?
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
You can insert a Object or String value inside the character, use a ChildAdded event, and then do the ui things.
OH , that’s a good idea i’ll see what i can do thx
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.
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
Ok i’ll be sure to see them! thx
no problem dude your welcom anyways