Why does this script only run once?

why does this only run once

local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local repStorage = game:GetService("ReplicatedStorage")

local event = repStorage.Remotes.ChangeSkin

local skin = ""

player.CharacterAdded:Connect(function()
    event:FireServer(skin)
end)

humanoid.Died:Connect(function()
    print("died")
    skin = character:WaitForChild("Marble").MaterialVariant
end)```

I recommend you to read the roblox docs below

The humanoid variable you have refers to the humanoid of the first character spawned. It doesn’t change when the player dies, so in the end it only applies to the already dead humanoid. I’d instead do something like this:

local player = players.LocalPlayer
local character
local humanoid

local repStorage = game:GetService("ReplicatedStorage")

local event = repStorage.Remotes.ChangeSkin

local skin = ""

player.CharacterAdded:Connect(function(char)
   character = char
   humanoid = character:WaitForChild("Humanoid")
    event:FireServer(skin)
end)

humanoid.Died:Connect(function()
    print("died")
    skin = character:WaitForChild("Marble").MaterialVariant
end)```