Anti Part Deleter

Hi, I’m making my anti part deleter which I’m trying to use for instances on my character, this is for personal use and I know about the anti tamper api for characters.
its basically supposed to see if something was removed from someone character and if so it will reload them and tp them back to their og position. its supposed to check for individual ones.

local char = game.Players.AmericanEagle124579.Character
local check_for = { 
	"Torso",
	"HumanoidRootPart",
	"LeftLeg",
	"RightLeg",
	"RightArm",
	"LeftArm",
	"Head",

	"CuteBlush2Accessory",
	"Fedora",
	"Skiis",
	"VoidAntlers",
	"Ultra-Fabulous Hair",
	"Vibe Check Baseball Bat",
	"Gold Rectangle Shades",
	"Shirt",
	"Pants",
	"Star Slayer Railgun"
}
local plrran = false
local hrppos

game.Workspace.ChildRemoved:Connect(function(ChildRemoved)
	if ChildRemoved.Name ~= table.concat(check_for," ") then
		
		return
	end

	if plrran then
		
		return
	end

	
	hrppos = char.HumanoidRootPart.CFrame
	game.Players.AmericanEagle124579:LoadCharacter()
	char.HumanoidRootPart.CFrame = hrppos
	plrran = true
	wait()
	plrran = false
end)

What’s wrong here? Are you running this on server?

You probably meant to use workspace.DescendantRemoved. Make sure the player who had an instance removed is you, though. Otherwise it could cause errors.

local Hats = { 
	"Torso",
	"HumanoidRootPart",
	"LeftLeg",
	"RightLeg",
	"RightArm",
	"LeftArm",
	"Head",

	"CuteBlush2Accessory",
	"Fedora",
	"Skiis",
	"VoidAntlers",
	"Ultra-Fabulous Hair",
	"Vibe Check Baseball Bat",
	"Gold Rectangle Shades",
	"Shirt",
	"Pants",
	"Star Slayer Railgun"
}
local Players = game:GetService("Players")
local CS = game:GetService("CollectionService")
function Check(Child:Instance?, Player:Player?)
	local Name = tostring(Child)
	if table.find(Hats, Name) then
		for _,v in Hats do
			if v:lower():match(Name:lower()) then
				local Position = Player.Character.HumanoidRootPart.Position
				Player:LoadCharacter()
				Player.Character:MoveTo(Position)
				task.wait()
				Position = nil
				break
			end
		end
	end
end
Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Character.DescendantRemoving:Connect(function(Child)
			if not CS:HasTag(Player, "CDH") then
				CS:AddTag(Player, "CDH")
				Check(Child, Player)
				task.delay(2,function()
					CS:RemoveTag(Player, "CDH")
				end)
			end
		end)
	end)
end)

Cleaned it a bit.

what is collection service exactly for?

Cooldown for each player that removed their hat.

is there a way to classify it to only run on one player. it’s not game wide.

That’s what it does, it only applies the cooldown to the player and not game wide.

but what is player defined as, I want it to run on the server and specify one player.

you can add a name check for that player.

Where do I define that, all I see is that player is defined in a function and not a callable field.