local function z(p)if p and p~=Workspace then local u=p:FindFirstChild("\072\117\109\097\110\111\105\100")if u then return p,u else return z(p.Parent)end end return nil end local function p(p)if p then local u,P=z(p.Parent)if P and P.Health>0 then local z=P:FindFirstChild("\072\105\116")if z then z:Invoke(0,CreatorTag)else print("\067\111\117\108\100 \110\111\116 \102\105\110\100 \066\105\110\100\097\098\108\101\070\117\110\099\116\105\111\110 \'\072\105\116\'")end end end end local function u(z)if Rocket and z then if ROCKET_IGNORE_LIST[string.lower(z.Name)]then return end local u=CreatorTag.Value if u and(u.Character and u.Character:IsAncestorOf(z))then return end local P=Instance.new("\069\120\112\108\111\115\105\111\110")P.BlastPressure=BLAST_PRESSURE P.BlastRadius=BLAST_RADIUS P.Position=Rocket.Position P.Hit:connect(p)P.Parent=Workspace local U=Rocket:FindFirstChild("\066\111\111\109")if U then U:Play()end local d=Rocket:FindFirstChild("\083\119\111\111\115\104")if d then d:Stop()end local T=Rocket:FindFirstChild("\070\105\114\101")if T then T:Destroy()end Rocket.Transparency=1 Rocket.CanCollide=false Rocket.Anchored=true DebrisService:AddItem(Rocket,3)Connection:disconnect()end end

local function FindCharacterAncestor(subject)
	if subject and subject ~= Workspace then
		local humanoid = subject:FindFirstChild('Humanoid')
		if humanoid then
			return subject, humanoid
		else
			return FindCharacterAncestor(subject.Parent)
		end
	end
	return nil
end

local function OnExplosionHit(hitPart)
	if hitPart then
		local _, humanoid = FindCharacterAncestor(hitPart.Parent)
		if humanoid and humanoid.Health > 0 then
			local hitBindable = humanoid:FindFirstChild('Hit')
			if hitBindable then
				hitBindable:Invoke(0, CreatorTag)
			else
				print("Could not find BindableFunction 'Hit'")
			end
		end
	end
end

local function OnTouched(otherPart)
	if Rocket and otherPart then
		-- Fly through anything in the ignore list
		if ROCKET_IGNORE_LIST[string.lower(otherPart.Name)] then
			return
		end

		-- Fly through the creator
		local myPlayer = CreatorTag.Value
		if myPlayer and myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
			return
		end

		-- Create the explosion
		local explosion = Instance.new('Explosion')
		explosion.BlastPressure = BLAST_PRESSURE
		explosion.BlastRadius = BLAST_RADIUS
		explosion.Position = Rocket.Position
		explosion.Hit:connect(OnExplosionHit)
		explosion.Parent = Workspace

		-- Start playing the boom sound
		local boomSound = Rocket:FindFirstChild('Boom')
		if boomSound then
			boomSound:Play()
		end

		-- NOTE:
		-- If we just destroyed the rocket at this point, the boom sound would be destroyed too,
		-- so instead we will hide the rocket, keep it in the same spot, and schedule it for deletion

		-- Stop playing the swoosh sound
		local swooshSound = Rocket:FindFirstChild('Swoosh')
		if swooshSound then
			swooshSound:Stop()
		end

		-- Put out the fire
		local fire = Rocket:FindFirstChild('Fire')
		if fire then
			fire:Destroy()
		end

		Rocket.Transparency = 1
		Rocket.CanCollide = false
		Rocket.Anchored = true
		DebrisService:AddItem(Rocket, 3)

		-- Destroy the connection so this method won't be called again
		Connection:disconnect()
	end
end
