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

Why doesn't this script get all of the children in the player and only delete the accessories?

this script is supposed to fetch the player and then get all of the accessories in the player and delete them. The script is a regular script in SSS.

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(char)
		if p.leaderstats["Time Played"].Value >= 100 then
			local children = char:GetChildren()
		for i = 1, #children do
			if (children[i].className == "Accessory") then
				children[i]:Remove()
			end
		end
		end
	end)
end)
		

1 comment

1 answer

Try this:

game.Players.PlayerAdded:Connect(function(p)
  p.CharacterAdded:Connect(function(char)
    wait(1) --wait for accessories to load (if any)
    local humanoid = char:WaitForChild("Humanoid")
    if p.leaderstats["Time Played"].Value >= 100 then
      humanoid:RemoceAccessories()
    end
  end)
end)

2 comments

0

did not work

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