------------------------------------------------------------------------------
--------------------[ MAIN PROGRAM ]------------------------------------------
------------------------------------------------------------------------------


local Touched = false

Main.Touched:connect(function(Obj)
	if IsIgnored(Obj) or Touched then return end
	Touched = true
	
	local W = Instance.new("Weld")
	W.Name = "Sticky"
	W.Part0 = Main
	W.Part1 = Obj
	W.C0 = Main.CFrame:toObjectSpace(Obj.CFrame)
	W.Parent = Main
	
	Main.ChildRemoved:connect(function(C)
		if C.Name == "Sticky" then
			local W = Instance.new("Weld")
			W.Name = "Sticky"
			W.Part0 = Main
			W.Part1 = Obj
			W.C0 = Main.CFrame:toObjectSpace(Obj.CFrame)
			W.Parent = Main
		end
	end)
	
	if Obj then
		if Obj.Parent.ClassName == "Hat" then
			local HitHumanoid = FindFirstClass(Obj.Parent.Parent, "Humanoid")
			if HitHumanoid and IsEnemy(HitHumanoid) then
				local CreatorTag = Instance.new("ObjectValue")
				CreatorTag.Name = "creator"
				CreatorTag.Value = Plyr
				CreatorTag.Parent = HitHumanoid
				HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
				MarkHit()
			end
		else
			local HitHumanoid = FindFirstClass(Obj.Parent, "Humanoid")
			if HitHumanoid and IsEnemy(HitHumanoid) then
				local CreatorTag = Instance.new("ObjectValue")
				CreatorTag.Name = "creator"
				CreatorTag.Value = Plyr
				CreatorTag.Parent = HitHumanoid
				HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
				MarkHit()
			end
		end
	end
	
	wait(3)
	
	Main.Parent:Destroy()
end)
