local F=game.Players local G=game.Players.LocalPlayer local h=script.Parent.Parent local l=h:WaitForChild("\072\105\116\080\108\097\121\101\114\115")local d=h:WaitForChild("\068\105\114\101\099\116\072\105\116\080\108\097\121\101\114")local o=h.Configuration local O={}function O.BindRocketEvents(y,O)local M=false O.PrimaryPart.Touched:connect(function(y)if not y:IsDescendantOf(G.Character)and not M then M=true O.PrimaryPart.LocalTransparencyModifier=1 h.RocketHit:FireServer(O,O.PrimaryPart.Position)local G=Instance.new("\080\097\114\116")G.Anchored=true G.CanCollide=false G.Position=O.PrimaryPart.Position G.FormFactor=Enum.FormFactor.Custom G.Shape=Enum.PartType.Ball G.Size=(Vector3.new(1,1,1)*o.BlastRadius.Value)*2 G.Parent=game.Workspace G.CanCollide=true local e={}local t=G:GetTouchingParts()G:Destroy()local L=F:GetPlayerFromCharacter(y.Parent)if L then d:FireServer(L.userId)end for G,h in ipairs(t)do local l=F:GetPlayerFromCharacter(h.Parent)if l and not e[tostring(l.userId)]then e[tostring(l.userId)]=true end end l:FireServer(e)end end)end return O

-- ROBLOX Services
local Players = game.Players

-- Local Variables
local Player = game.Players.LocalPlayer
local Tool = script.Parent.Parent
local HitPlayer = Tool:WaitForChild('HitPlayers')
local DirectHitPlayer = Tool:WaitForChild('DirectHitPlayer')
local Configurations = Tool.Configuration
local RocketManager = {}

function RocketManager:BindRocketEvents(rocket)
	local exploded = false
	
	rocket.PrimaryPart.Touched:connect(function(otherPart)
		if not otherPart:IsDescendantOf(Player.Character) and not exploded then
			exploded = true
			rocket.PrimaryPart.LocalTransparencyModifier = 1
			Tool.RocketHit:FireServer(rocket, rocket.PrimaryPart.Position)
			local collision = Instance.new('Part')
			collision.Anchored = true
			collision.CanCollide = false
			collision.Position = rocket.PrimaryPart.Position
			collision.FormFactor = Enum.FormFactor.Custom
			collision.Shape = Enum.PartType.Ball
			collision.Size = Vector3.new(1,1,1) * Configurations.BlastRadius.Value * 2
			collision.Parent = game.Workspace
			collision.CanCollide = true
			local hitPlayers = {}
			local hitParts = collision:GetTouchingParts()
			collision:Destroy()
			local player = Players:GetPlayerFromCharacter(otherPart.Parent)
			if player then DirectHitPlayer:FireServer(player.userId) end
			for _, hitPart in ipairs(hitParts) do
				local player = Players:GetPlayerFromCharacter(hitPart.Parent)
				if player and not hitPlayers[tostring(player.userId)] then hitPlayers[tostring(player.userId)] = true end
			end
			HitPlayer:FireServer(hitPlayers)
		end
	end)
end

return RocketManager
