Tool=script.Parent Handle=Tool:WaitForChild("\072\097\110\100\108\101")Players=game:GetService("\080\108\097\121\101\114\115")Debris=game:GetService("\068\101\098\114\105\115")Speed=250 Duration=1 NozzleOffset=Vector3.new(0,.4,-1.1)Sounds={Fire=Handle:WaitForChild("\070\105\114\101"),Reload=Handle:WaitForChild("\082\101\108\111\097\100");HitFade=Handle:WaitForChild("\072\105\116\070\097\100\101")}PointLight=Handle:WaitForChild("\080\111\105\110\116\076\105\103\104\116")ServerControl=Tool:FindFirstChild("\083\101\114\118\101\114\067\111\110\116\114\111\108")or Instance.new("\082\101\109\111\116\101\070\117\110\099\116\105\111\110")ServerControl.Name="\083\101\114\118\101\114\067\111\110\116\114\111\108"ServerControl.Parent=Tool ClientControl=Tool:FindFirstChild("\067\108\105\101\110\116\067\111\110\116\114\111\108")or Instance.new("\082\101\109\111\116\101\070\117\110\099\116\105\111\110")ClientControl.Name="\067\108\105\101\110\116\067\111\110\116\114\111\108"ClientControl.Parent=Tool ServerControl.OnServerInvoke=function(Q,i,N,B)if Q~=Player or Humanoid.Health==0 or not Tool.Enabled then return end if i=="\067\108\105\099\107"and N then Activated(B)end end function InvokeClient(Q,i)pcall(function()ClientControl:InvokeClient(Player,Q,i)end)end function TagHumanoid(Q,i)local N=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")N.Name="\099\114\101\097\116\111\114"N.Value=i Debris:AddItem(N,2)N.Parent=Q end function UntagHumanoid(Q)for Q,i in pairs(Q:GetChildren())do if i:IsA("\079\098\106\101\099\116\086\097\108\117\101")and i.Name=="\099\114\101\097\116\111\114"then i:Destroy()end end end function FindCharacterAncestor(Q)if Q and Q~=game:GetService("\087\111\114\107\115\112\097\099\101")then local i=Q:FindFirstChild("\072\117\109\097\110\111\105\100")if i then return Q,i else return FindCharacterAncestor(Q.Parent)end end return nil end function GetTransparentsRecursive(Q,i)local N=i or{}for Q,i in pairs(Q:GetChildren())do local B=false pcall(function()local Q=i.Transparency if Q then B=true end end)if B then table.insert(N,i)end GetTransparentsRecursive(i,N)end return N end function SelectionBoxify(Q)local i=Instance.new("\083\101\108\101\099\116\105\111\110\066\111\120")i.Adornee=Q i.Color=BrickColor.new("\084\111\111\116\104\112\097\115\116\101")i.Parent=Q return i end local function Q(Q)local i=PointLight:Clone()i.Range=i.Range+2 i.Parent=Q end function FadeOutObjects(Q,i)repeat local N=nil for Q,B in pairs(Q)do B.Transparency=B.Transparency+i N=B end wait()until N.Transparency>=1 or not N end function Dematerialize(i,N,B)if not i or not N then return end N.WalkSpeed=0 local V={}for Q,i in pairs(i:GetChildren())do if i:IsA("\066\097\115\101\080\097\114\116")then i.Anchored=true table.insert(V,i)elseif i:IsA("\076\111\099\097\108\083\099\114\105\112\116")or i:IsA("\083\099\114\105\112\116")then i:Destroy()end end local h={}local O=SelectionBoxify(B)Q(B)wait(.05)for i,N in pairs(V)do if N~=B then table.insert(h,SelectionBoxify(N))Q(N)end end local H=GetTransparentsRecursive(i)FadeOutObjects(H,.1)wait(.5)i:BreakJoints()N.Health=0 Debris:AddItem(i,2)local P=.05 Delay(.2,function()FadeOutObjects({O},P)if i and i.Parent then i:Destroy()end end)FadeOutObjects(h,P)end function Touched(Q,i)if not i or not i.Parent then return end local N,B=FindCharacterAncestor(i)if N and(B and N~=Character)then local V=false for Q,i in pairs(N:GetChildren())do if i:IsA("\070\111\114\099\101\070\105\101\108\100")then V=true end end if not V then if Q then local i=Q:FindFirstChild(Sounds.HitFade.Name)local N=B.Torso if i and N then i.Parent=N i:Play()end end Dematerialize(N,B,i)end if Q and Q.Parent then Q:Destroy()end end end function Equipped()Character=Tool.Parent Player=Players:GetPlayerFromCharacter(Character)Humanoid=Character:FindFirstChild("\072\117\109\097\110\111\105\100")if not Player or not Humanoid or Humanoid.Health==0 then return end end function Activated(Q)if Tool.Enabled and Humanoid.Health>0 then Tool.Enabled=false InvokeClient("\080\108\097\121\083\111\117\110\100",Sounds.Fire)local i=Handle.CFrame local N=i.p+i:vectorToWorldSpace(NozzleOffset)local B=CFrame.new(N,Q)local V=BaseShot:Clone()V.CFrame=B+B.lookVector*(BaseShot.Size.Z/2)local h=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")h.velocity=B.lookVector*Speed h.Parent=V V.Touched:connect(function(Q)if not Q or not Q.Parent then return end Touched(V,Q)end)Debris:AddItem(V,Duration)V.Parent=game:GetService("\087\111\114\107\115\112\097\099\101")wait(.6)InvokeClient("\080\108\097\121\083\111\117\110\100",Sounds.Reload)wait(.75)Tool.Enabled=true end end function Unequipped() end BaseShot=Instance.new("\080\097\114\116")BaseShot.Name="\069\102\102\101\099\116"BaseShot.BrickColor=BrickColor.new("\084\111\111\116\104\112\097\115\116\101")BaseShot.Material=Enum.Material.Plastic BaseShot.Shape=Enum.PartType.Block BaseShot.TopSurface=Enum.SurfaceType.Smooth BaseShot.BottomSurface=Enum.SurfaceType.Smooth BaseShot.FormFactor=Enum.FormFactor.Custom BaseShot.Size=Vector3.new(.2,.2,3)BaseShot.CanCollide=false BaseShot.Locked=true SelectionBoxify(BaseShot)Q(BaseShot)BaseShotSound=Sounds.HitFade:Clone()BaseShotSound.Parent=BaseShot Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)
--Rescripted by Luckymaxer

Tool = script.Parent
Handle = Tool:WaitForChild("Handle")

Players = game:GetService("Players")
Debris = game:GetService("Debris")

Speed = 250
Duration = 1

NozzleOffset = Vector3.new(0, 0.4, -1.1)

Sounds = {
	Fire = Handle:WaitForChild("Fire"),
	Reload = Handle:WaitForChild("Reload"),
	HitFade = Handle:WaitForChild("HitFade"),
}

PointLight = Handle:WaitForChild("PointLight")

ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
ServerControl.Name = "ServerControl"
ServerControl.Parent = Tool

ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
ClientControl.Name = "ClientControl"
ClientControl.Parent = Tool

ServerControl.OnServerInvoke = function(player, Mode, Value, arg)
	if player ~= Player or Humanoid.Health == 0 or not Tool.Enabled then
		return
	end
	if Mode == "Click" and Value then
		Activated(arg)
	end
end

function InvokeClient(Mode, Value)
	pcall(function()
		ClientControl:InvokeClient(Player, Mode, Value)
	end)
end

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

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

function GetTransparentsRecursive(Parent, PartsTable)
	local PartsTable = (PartsTable or {})
	for i, v in pairs(Parent:GetChildren()) do
		local TransparencyExists = false
		pcall(function()
			local Transparency = v["Transparency"]
			if Transparency then
				TransparencyExists = true
			end
		end)
		if TransparencyExists then
			table.insert(PartsTable, v)
		end
		GetTransparentsRecursive(v, PartsTable)
	end
	return PartsTable
end

function SelectionBoxify(Object)
	local SelectionBox = Instance.new("SelectionBox")
	SelectionBox.Adornee = Object
	SelectionBox.Color = BrickColor.new("Toothpaste")
	SelectionBox.Parent = Object
	return SelectionBox
end

local function Light(Object)
	local Light = PointLight:Clone()
	Light.Range = (Light.Range + 2)
	Light.Parent = Object
end

function FadeOutObjects(Objects, FadeIncrement)
	repeat
		local LastObject = nil
		for i, v in pairs(Objects) do
			v.Transparency = (v.Transparency + FadeIncrement)
			LastObject = v
		end
		wait()
	until LastObject.Transparency >= 1 or not LastObject
end

function Dematerialize(character, humanoid, FirstPart)
	if not character or not humanoid then
		return
	end

	humanoid.WalkSpeed = 0

	local Parts = {}

	for i, v in pairs(character:GetChildren()) do
		if v:IsA("BasePart") then
			v.Anchored = true
			table.insert(Parts, v)
		elseif v:IsA("LocalScript") or v:IsA("Script") then
			v:Destroy()
		end
	end

	local SelectionBoxes = {}

	local FirstSelectionBox = SelectionBoxify(FirstPart)
	Light(FirstPart)
	wait(0.05)

	for i, v in pairs(Parts) do
		if v ~= FirstPart then
			table.insert(SelectionBoxes, SelectionBoxify(v))
			Light(v)
		end
	end

	local ObjectsWithTransparency = GetTransparentsRecursive(character)
	FadeOutObjects(ObjectsWithTransparency, 0.1)

	wait(0.5)

	character:BreakJoints()
	humanoid.Health = 0

	Debris:AddItem(character, 2)

	local FadeIncrement = 0.05
	Delay(0.2, function()
		FadeOutObjects({ FirstSelectionBox }, FadeIncrement)
		if character and character.Parent then
			character:Destroy()
		end
	end)
	FadeOutObjects(SelectionBoxes, FadeIncrement)
end

function Touched(Projectile, Hit)
	if not Hit or not Hit.Parent then
		return
	end
	local character, humanoid = FindCharacterAncestor(Hit)
	if character and humanoid and character ~= Character then
		local ForceFieldExists = false
		for i, v in pairs(character:GetChildren()) do
			if v:IsA("ForceField") then
				ForceFieldExists = true
			end
		end
		if not ForceFieldExists then
			if Projectile then
				local HitFadeSound = Projectile:FindFirstChild(Sounds.HitFade.Name)
				local torso = humanoid.Torso
				if HitFadeSound and torso then
					HitFadeSound.Parent = torso
					HitFadeSound:Play()
				end
			end
			Dematerialize(character, humanoid, Hit)
		end
		if Projectile and Projectile.Parent then
			Projectile:Destroy()
		end
	end
end

function Equipped()
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChild("Humanoid")
	if not Player or not Humanoid or Humanoid.Health == 0 then
		return
	end
end

function Activated(target)
	if Tool.Enabled and Humanoid.Health > 0 then
		Tool.Enabled = false

		InvokeClient("PlaySound", Sounds.Fire)

		local HandleCFrame = Handle.CFrame
		local FiringPoint = HandleCFrame.p + HandleCFrame:vectorToWorldSpace(NozzleOffset)
		local ShotCFrame = CFrame.new(FiringPoint, target)

		local LaserShotClone = BaseShot:Clone()
		LaserShotClone.CFrame = ShotCFrame + (ShotCFrame.lookVector * (BaseShot.Size.Z / 2))
		local BodyVelocity = Instance.new("BodyVelocity")
		BodyVelocity.velocity = ShotCFrame.lookVector * Speed
		BodyVelocity.Parent = LaserShotClone
		LaserShotClone.Touched:connect(function(Hit)
			if not Hit or not Hit.Parent then
				return
			end
			Touched(LaserShotClone, Hit)
		end)
		Debris:AddItem(LaserShotClone, Duration)
		LaserShotClone.Parent = game:GetService("Workspace")

		wait(0.6) -- FireSound length

		InvokeClient("PlaySound", Sounds.Reload)

		wait(0.75) -- ReloadSound length

		Tool.Enabled = true
	end
end

function Unequipped() end

BaseShot = Instance.new("Part")
BaseShot.Name = "Effect"
BaseShot.BrickColor = BrickColor.new("Toothpaste")
BaseShot.Material = Enum.Material.Plastic
BaseShot.Shape = Enum.PartType.Block
BaseShot.TopSurface = Enum.SurfaceType.Smooth
BaseShot.BottomSurface = Enum.SurfaceType.Smooth
BaseShot.FormFactor = Enum.FormFactor.Custom
BaseShot.Size = Vector3.new(0.2, 0.2, 3)
BaseShot.CanCollide = false
BaseShot.Locked = true
SelectionBoxify(BaseShot)
Light(BaseShot)
BaseShotSound = Sounds.HitFade:Clone()
BaseShotSound.Parent = BaseShot

Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
