When the player dies its supposed freeze it and put a highlight on the player and map but It keeps giving me this error
heres the code as well
game.Players.LocalPlayer.CharacterAdded:Connect(function()
local player = game.Players.LocalPlayer
local ServerStorage = game:GetService("ServerStorage")
local char = player.Character
repeat
wait()
char = player.Character
until char ~= nil
local humanoid = char:WaitForChild("Humanoid")
local function died()
if char.Humanoid.Health == 0 then
while char.Humanoid.HumanoidStateType.Dead == true do
local map_highlight = ServerStorage.HighlightMap:Clone().Parent == game.Workspace.MapModel
end
else
end
end
humanoid.Died:Connect(died)
repeat wait() until char.Humanoid.HumanoidStateType.Dead == false
local remove_highlight = game.Workspace.MapModel.HighlightMap
remove_highlight:Destroy()
end)```