Hi, I"m making a system where when you die, a gui and blur shows up on your screen. This is achieved using Humanoid.Died. However, I have printed a statement every time the function fires, but it prints once, if I die again after that, it doesn’t print. Here’s my code:
IF the script isnt parented to the character, the humanoid will not change to the new humanoid when the player respawns.
To resolve this. when the character is added, set the humanoid to the new humanoid, this should fix it.
OR, you can put this script inside a Gui and set ResetOnSpawn to true.
New Script(Solution 1)
--# Services
local PlayerService = game:GetService("Players")
--# Objects
local player = PlayerService.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
--# Functions
function onDeath()
print(`{player.Name} died.`)
-- rest of your script...
end
function Respawned(model:Model)
humanoid = model:WaitForChild("Humanoid")
end
--# Connections
humanoid.Died:Connect(onDeath)
player.CharacterAdded:Connect(Respawned)