Hello, I Made a script that hides the player after dying or destroys the player from Workspace after dying, so the script is working good but the problem that it made another script i made doesn’t work, can anyone help??
the destroying after dying script
local Players = game:GetService(“Players”)
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild(“Humanoid”)
humanoid.Died:Connect(function()
-- Wait for 1 second before removing the character from the workspace
wait(1)
-- Remove the character from the workspace
character.Parent = nil
end)
end)
end)
the script that doesn’t work anymore after making the destroying script
local player = game.Players.LocalPlayer
local gui = script.Parent
local frame = gui:WaitForChild(“DeathScreen”) – Change “Frame” to your frame’s name if different
– Function to handle when player dies
local function onPlayerDied()
frame.Visible = true
end
– Function to connect player character events
local function onCharacterAdded(character)
frame.Visible = false – Hide the frame when the player respawns
local humanoid = character:WaitForChild(“Humanoid”)
humanoid.Died:Connect(onPlayerDied)
end
– Connect the CharacterAdded event
player.CharacterAdded:Connect(onCharacterAdded)
– Check if the character already exists when the game starts
if player.Character then
onCharacterAdded(player.Character)
end