Hello, and I have made health gui, and the problem it’s working with other parts, like killpart or sword, the health really shows, but the problem is with parts, that takes small damage but fast, like in first image.
Script for parts, that breaks health bar (local script in StarterCharacterScripts)
for i, v in pairs(game.Workspace:GetDescendants()) do
if v:IsA("Part") and v:FindFirstChild("DamageCount") then
local DamageCount = v.DamageCount.Value
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
humanoid:TakeDamage(DamageCount)
debounce = true
wait(0.1)
debounce = false
end
end)
end
end
Script for health bar (Server script in ServerScriptService)
local function round(n)
return math.floor(n + 0.5)
end
newTag.HealthText.Text = round(Humanoid.Health).."/"..Humanoid.MaxHealth
Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
newTag.Health:TweenSize(UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,0.2,0),"Out","Back",.25)
newTag.HealthText.Text = round(Humanoid.Health).."/"..Humanoid.MaxHealth
end)
Thanks for your help!