local t=game:GetService("\067\111\108\108\101\099\116\105\111\110\083\101\114\118\105\099\101")local U=game:GetService("\068\101\098\114\105\115")local function D(D,j)if Tool.Enabled==false then return end local u=ModFx.GetPlayerFromTool(Tool)if D~=u then return end local L=D.Character if not L then return end local T=L:FindFirstChildWhichIsA("\072\117\109\097\110\111\105\100")local b=L:FindFirstChildWhichIsA("\084\111\111\108")local P=L:FindFirstChild("\072\101\097\100")if not P or not b or not T then return end if b~=Tool then return end if T.Health<=0 then return end Tool.Enabled=false local k=j-P.Position k=k*(1/k.magnitude)local q=P.Position+k*8 local X=5000 local O=Rocket:clone()O.Name="\082\111\099\107\101\116"local W=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")W.Parent=O W.P=12500 W.MaxForce=Vector3.new(X,X,X)W.Velocity=k*60 O.CFrame=CFrame.new(q,q+k)local C=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")C.Value=D C.Name="\099\114\101\097\116\111\114"C.Parent=O local x=Tool.Handle.exp:Clone()x.PlaybackSpeed=math.random(90,110)/100 x.PlayOnRemove=true x.Parent=O local I=Tool.Handle.swoosh:Clone()I.PlaybackSpeed=math.random(95,105)/100 I.Parent=O O.Parent=workspace t:AddTag(O,O.Name)t:AddTag(O,D.Name)O:SetNetworkOwner(D)I:Play()local Z=D:FindFirstChild("\069\102\102\101\099\116")if Z and Z.Value~="\078\111\110\101"then if Z.Value=="\070\105\114\101"then Instance.new("\070\105\114\101",O)else spawn(function()(require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).TrailModule)).AddTrail(O,Z.Value,.5,.5,1)end)end end U:AddItem(O,10)wait(7)Tool.Enabled=true end Tool.Fire.OnServerEvent:Connect(D)local function j(D,j,u)local L=true local T,b=pcall(function()if j:GetNetworkOwner()~=D then L=false end end)if b then warn(D.Name.." \109\097\121 \098\101 \101\120\112\108\111\105\116\105\110\103")return end if L==false then warn(D.Name.." \105\115 \100\101\102\105\110\105\116\101\108\121 \101\120\112\108\111\105\116\105\110\103")return end local P=j.Position local k=j:FindFirstChild("\099\114\101\097\116\111\114")local q if k then q=k.Value end local X=ModFx.GetPlayerFromTool(Tool)if q~=nil and(q==D and(X and(X==D and((P-u).magnitude<20 and(t:HasTag(j,j.Name)and t:HasTag(j,D.Name))))))then j:ClearAllChildren()U:AddItem(j,0)ModFx.Explosion(q,"\082\111\099\107\101\116",u)end end Tool.RocketDestroyEvent.OnServerEvent:connect(j)
--local Player=ModFx.GetPlayerFromTool(Tool) --[[This will be refreshed throughout the script
--											so that if someone wanted to make the tools
--											droppable, itd work with other players	]]
-- commented cause its useless as a global variable, however not deleted so as to keep the above comments
local ColSer = game:GetService("CollectionService")
local Debris = game:GetService("Debris")

local function FireWep(plr, targetPos)
	if Tool.Enabled == false then
		return
	end
	local Player = ModFx.GetPlayerFromTool(Tool)
	if plr ~= Player then
		return
	end
	local c = plr.Character
	if not c then
		return
	end
	local h = c:FindFirstChildWhichIsA("Humanoid")
	local plrTool = c:FindFirstChildWhichIsA("Tool")
	local Head = c:FindFirstChild("Head")
	if not Head or not plrTool or not h then
		return
	end
	if plrTool ~= Tool then
		return
	end
	if h.Health <= 0 then
		return
	end

	Tool.Enabled = false

	local dir = targetPos - Head.Position
	dir = dir * (1 / dir.magnitude)

	local pos = Head.Position + (dir * 8)
	local ad = 5000

	local missile = Rocket:clone()
	missile.Name = "Rocket"

	local BV = Instance.new("BodyVelocity")
	BV.Parent = missile
	BV.P = 12500
	BV.MaxForce = Vector3.new(ad, ad, ad)
	BV.Velocity = dir * 60
	missile.CFrame = CFrame.new(pos, pos + dir)

	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = plr
	creator_tag.Name = "creator"
	creator_tag.Parent = missile

	local exp = Tool.Handle.exp:Clone()
	exp.PlaybackSpeed = math.random(90, 110) / 100
	exp.PlayOnRemove = true
	exp.Parent = missile

	local swoosh = Tool.Handle.swoosh:Clone()
	swoosh.PlaybackSpeed = math.random(95, 105) / 100
	swoosh.Parent = missile

	missile.Parent = workspace
	ColSer:AddTag(missile, missile.Name)
	ColSer:AddTag(missile, plr.Name)
	missile:SetNetworkOwner(plr)
	swoosh:Play()

	local effect = plr:FindFirstChild("Effect")
	if effect and effect.Value ~= "None" then
		if effect.Value == "Fire" then
			Instance.new("Fire", missile)
		else
			spawn(function()
				require(game:GetService("ReplicatedStorage").TrailModule).AddTrail(missile, effect.Value, 0.5, 0.5, 1)
			end)
		end
	end
	Debris:AddItem(missile, 10)
	wait(7)
	Tool.Enabled = true
end

Tool.Fire.OnServerEvent:Connect(FireWep)

local function DestroyRocket(plr, Obj, ClientPos)
	local x = true
	local succ, err = pcall(function()
		if Obj:GetNetworkOwner() ~= plr then
			x = false
		end
	end)
	if err then
		warn(plr.Name .. " may be exploiting")
		return
	end -- Not sure how this would happen.
	if x == false then
		warn(plr.Name .. " is definitely exploiting") --[[plr:Kick("Possible exploit detected")]]
		return
	end
	--[[ Why am I so confident that they're an exploiter if x==false? Because the network owner of the rocket is SET (as opposed to using auto 
	network ownership) to the rocket's firer, and so if the part this remote is firing upon is NOT owned by the user firing the remote, then I 
	know the remote is being fired externally. ]]
	local ServerPos = Obj.Position
	local creator = Obj:FindFirstChild("creator")
	local CreatorValue
	if creator then
		CreatorValue = creator.Value
	end
	local Player = ModFx.GetPlayerFromTool(Tool)
	if
		CreatorValue ~= nil
		and CreatorValue == plr
		and Player
		and Player == plr
		and (ServerPos - ClientPos).magnitude < 20
		and ColSer:HasTag(Obj, Obj.Name)
		and ColSer:HasTag(Obj, plr.Name)
	then -- all these to ensure that it's a rocket, and its their rocket, and its from their tool
		-- "(ServerPos - ClientPos).magnitude" = the distance between the serverside and clientside missile on hit
		Obj:ClearAllChildren()
		Debris:AddItem(Obj, 0)
		ModFx.Explosion(CreatorValue, "Rocket", ClientPos)
	end
end

Tool.RocketDestroyEvent.OnServerEvent:connect(DestroyRocket)
