Hello, I am trying to make a combat system and I have the core mechanics are completed. However, I am currently adding effects/sounds etc.
I know a lot of game makes an entity/humanoid flesh red for a second upon damaged but I do not know how to make a humanoid (made out of mesh parts and are textured) red
I am not asking for an entire script or system but can anybody give me a function or something that makes a textured mesh part changes color
If the entity has a humanoid instance you can listen to its “.HealthChanged” event, here’s an example.
local npc = script.Parent
local humanoid = npc.Humanoid
humanoid.HealthChanged:Connect(function(health)
if health <= 50 then --Change this to desired health.
for _, child in ipairs(npc:GetChildren()) do
if child:IsA("BasePart") then
child.Color = Color3.new(1, 0, 0)
end
end
end
end)
If you don’t feel like making a red version of every single texture I recommend replication.
Simply clone all of the meshparts in their current positions and remove the textures from the clones. Then turn the clones red and make them slightly bigger. You could also make it special by tweening it to scale bigger and more transparent over a 1/2 second interval.
Make sure the cloned parts are non-collide, non-interact, and are anchored. Also, you might want to remove CastShadow from the parts for optimization purposes.