Unable to remove all BoolValues

Hello,
Currently I am trying to write a script that removes a player’s BoolValues when they die. It doesn’t work, however there don’t seem to be any errors in the Output.

The script (ServerScript in ServerScriptService):

game.Players.PlayerAdded:Connect(function(player)
	player:WaitForChild('Humanoid').Died:Connect(function()
		local descendants = game.Players:GetDescendants()
		for i,v in pairs(descendants) do
			if v:IsA("BoolValue") then
				v:Destroy()
				print("BoolValues destroyed")
			end
		end
	end)
end)

Thank you for your help!

Here a script I made for you:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		char.Humanoid.Died:Connect(function()
			local descendants = player:GetDescendants()
			for i,v in pairs(descendants) do
				if v:IsA("BoolValue") then
					v:Destroy()
					print("BoolValues destroyed")
				end
			end
		end)
	end)
end)
1 Like