Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a character respawn with hats?

Asked by 4 years ago

can someone help me figure out how to make a player respawn with hats? I got it to where it removes their hats and adds hats to them but idk how to make it so that if they die they spawn with them again

Code:

local Players = game:GetService("Players")

local function playerAdded(player)
    player.CharacterAppearanceLoaded:Connect(function(character)
        local humanoid = character:WaitForChild("Humanoid")


        humanoid:RemoveAccessories()


end)
end


for _, player in pairs(Players:GetPlayers()) do 
    playerAdded(player)
end

Players.PlayerAdded:Connect(playerAdded)

        game.Players.PlayerAdded:connect(function(player)
       repeat wait()until player.Character
        local hatId = 4753644287
        local hatId2 = 63650436

        local hat = game:service("InsertService"):LoadAsset(hatId):GetChildren()[1]
        hat.Parent=player.Character

        local hat = game:service("InsertService"):LoadAsset(hatId2):GetChildren()[1]
        hat.Parent=player.Character
        end)

Answer this question