The script here does not even fire the :GetPropertyChangedSignal event. This is a local script inside the StarterCharacter. Damage taken from the client fires the event, but if it is taken from the server, it does not. Does anyone know why it does not update when damage is taken from the server?

local Plr = game.Players.LocalPlayer
local Chr = script.Parent
local Hum = Chr:WaitForChild("Humanoid")
local HealthBar = Plr.PlayerGui.PlayerInterface.TopBar.Health
local TS = game:GetService("TweenService")

local TweenTime = 0.5
local TI = TweenInfo.new(TweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, true)
HealthBar.Size = UDim2.new(0.075, 0,0.25, 0)

local PrevHp = Hum.MaxHealth

Hum:GetPropertyChangedSignal("Health"):Connect(function()
	print("Health changed")
	HealthBar.Size = UDim2.new(0.075 * Hum.Health / Hum.MaxHealth, 0,0.25, 0)
	spawn(function()
		if Hum.Health < PrevHp then
			local Gui = script.TakeDamageEffect:Clone()
			Gui.Parent = Plr.PlayerGui
			local Tween = TS:Create(Gui.Effect, TI, {["ImageTransparency"] = 0})
			Tween:Play() 
			delay(TweenTime * 2, function()
				Gui:Destroy()
			end)
		end
		PrevHp = Hum.Health
	end)
end)

3 comments

2

use Humanoid.HealthChanged  

0

Works, thanks :DDD