plr = game.Players.LocalPlayer chr = game:GetService("Workspace"):WaitForChild(plr.Name) human = chr:WaitForChild("Humanoid") ui = plr.PlayerGui:WaitForChild("base") rs = game:GetService("ReplicatedStorage") human.HealthChanged:Connect(function() ui.health.value.Text = human.Health if human.Health <= 0 then game:GetService("Lighting").Blur.Enabled = true rs.health:FireServer() end end) plr.CharacterAdded:Connect(function() game:GetService("Lighting").Blur.Enabled = false end)
this script works only one time....then when the player's character is added it doesn't update the ui.health.Value.Text (it stays 0) and the screen isn't blured if he dies again...i figured out that the human.HealthChanged isn't happening anymore but i don't know why
(a local script inside StarterPlayerScripts)
(sorry i am not a native english speaker)
The problem When a player respawns and character is created again, it creates a new Humanoid. The human.HealthChanged function uses the old Humanoid and so it won't fire for the new Humanoid.
Option 1 Use StarterCharacterScripts in order to have the LocalScript be remade every time the character dies.
Option 2
Use Player.CharacterAdded
plr.CharacterAdded:Connect(function(chr) local human = chr:WaitForChild("Humanoid") human.HealthChanged:Connect(function() ui.health.value.Text = human.Health if human.Health <= 0 then game:GetService("Lighting").Blur.Enabled = true rs.health:FireServer() end end) end)