I try to test abut when i dies it will still on my head but i got error which is
Humanoid is not a valid member of Player “Players.DylTheDeveloperX” line 5
script
local equipTable = {}
game.Players.ChildAdded:Connect(function(char)
local haloName = equipTable[char.Name]
local hum = char.Humanoid
if haloName then
hum:AddAccessory(game.ServerStorage.Black[haloName]:Clone())
equipTable[char.Name] = nil
end
hum.Died:Connect(function()
for _,Black in pairs(hum:GetAccessories()) do
if not string.find(Black.Name, "Black") then continue end
equipTable[char.Name] = Black.Name
break
end
end)
end)
Your using the childed added event. That “char” will actaully be the player not the players character.
I recommend to use the PlayerAdded event. After that use the player:CharacterAdded event to get the actual character of the player.
Try using this:
local equipTable = {}
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local haloName = equipTable[char.Name]
local hum = char.Humanoid
if haloName then
hum:AddAccessory(game.ServerStorage.Black[haloName]:Clone())
equipTable[char.Name] = nil
end
hum.Died:Connect(function()
for _,Black in pairs(hum:GetAccessories()) do
if not string.find(Black.Name, "Black") then continue end
equipTable[char.Name] = Black.Name
break
end
end)
end)
end)
1 Like