Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Removing accessories on death?

just here is the code

(BTW this is a script and I know it should be working but it's not...)

game:GetService('Players').PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(charModel)
        local hum = charModel:WaitForChild('Humanoid')

        hum.Died:Connect(function()
            hum:RemoveAccessories()
        end)
    end)
end)

Thank you

2 comments

0

What happen when the script run?

0

Nothing

1 answer

I'm not sure :RemoveAccessories() is a function of humanoid. Either way, this code should work:

game:GetService('Players').PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(charModel)
		local hum = charModel:WaitForChild('Humanoid')

		hum.Died:Connect(function()
			for each, thing in pairs(hum.Parent:GetChildren()) do
				if thing:IsA("Accessory") then thing:Destroy() end
			end
		end)
	end)
end)

4 comments

0

:RemoveAccessories() is a function of the humanoid

0

No that doesn't work

0

Doesn't the accessories get destroyed after the player dies?

0

No

This discussion is preserved as it was. New answers, comments, and votes are closed.