I have programmed code that adjusts the material of player accessories when their character loads into the game. However, when enabling Deferred
for the SignalBehavior
property, my code no longer finishes running as intended.
game.Players.PlayerAdded:Connect(function(PLAYER)
print("Player Added")
PLAYER.CharacterAdded:Connect(function(CHARACTER)
print("Character Added")
PLAYER.CharacterAppearanceLoaded:Connect(function()
print("Character Appearance Loaded")
for INDEX, DESCENDANT in pairs (CHARACTER:GetDescendants()) do
if CHARACTER then
if DESCENDANT.Name == "Handle" then
DESCENDANT.Material = Enum.Material.Glass
end
end
end
end)
CHARACTER:WaitForChild("Humanoid").Died:Connect(function()
PLAYER:LoadCharacter()
end)
end)
end)
In this code, “Player Added” and “Character Added” are both printed, but “Character Appearance Loaded” is not.
If I’m understanding correctly, I need to make changes to the embedded events to run as intended with Deferred SignalBehavior, but I’m not sure where to start or what I need to do. Can anyone point me in the right direction?