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")BulletSpeed=Handle.BulletSpeed.Value DisappearTime=Handle.BulletDisappearTime.Value ReloadTime=Handle.ReloadTime.Value BulletColor=Handle.BulletColor.Value 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(M,B,P,V)if M~=Player or Humanoid.Health==0 or not Tool.Enabled then return end if B=="\067\108\105\099\107"and P then Activated(V)end end function InvokeClient(M,B)pcall(function()ClientControl:InvokeClient(Player,M,B)end)end function TagHumanoid(M,B)local P=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")P.Name="\099\114\101\097\116\111\114"P.Value=B Debris:AddItem(P,2)P.Parent=M end function UntagHumanoid(M)for M,B in pairs(M:GetChildren())do if B:IsA("\079\098\106\101\099\116\086\097\108\117\101")and B.Name=="\099\114\101\097\116\111\114"then B:Destroy()end end end function FindCharacterAncestor(M)if M and M~=game:GetService("\087\111\114\107\115\112\097\099\101")then local B=M:FindFirstChild("\072\117\109\097\110\111\105\100")if B then return M,B else return FindCharacterAncestor(M.Parent)end end return nil end function GetTransparentsRecursive(M,B)local P=B or{}for M,B in pairs(M:GetChildren())do local V=false pcall(function()local M=B.Transparency if M then V=true end end)if V then table.insert(P,B)end GetTransparentsRecursive(B,P)end return P end function SelectionBoxify(M)local B=Instance.new("\083\101\108\101\099\116\105\111\110\066\111\120")B.Adornee=M B.Color3=BulletColor B.Parent=M return B end local function M(M)local B=PointLight:Clone()B.Range=B.Range+2 B.Parent=M end function FadeOutObjects(M,B)repeat local P=nil for M,V in pairs(M)do V.Transparency=V.Transparency+B P=V end wait()until P.Transparency>=1 or not P end function Touched(M,B)if not B or not B.Parent then return end local P,V=FindCharacterAncestor(B)if P and(V and P~=Character)then local B=false for M,P in pairs(P:GetChildren())do if P:IsA("\070\111\114\099\101\070\105\101\108\100")then B=true end end if not B then if M then local B=M:FindFirstChild(Sounds.HitFade.Name)local P=V.Torso if B and P then local M=B:Clone()M.Parent=P M:Play()end end end V.Health-=10 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(M)if Tool.Enabled and Humanoid.Health>0 then Tool.Enabled=false InvokeClient("\080\108\097\121\083\111\117\110\100",Sounds.Fire)local B=Handle.CFrame local P=B.p+B:vectorToWorldSpace(NozzleOffset)local V=CFrame.new(P,M)local z=BaseShot:Clone()z.CFrame=V+V.lookVector*(BaseShot.Size.Z/2)local Q=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")Q.velocity=V.lookVector*BulletSpeed Q.Parent=z z.Touched:connect(function(M)if not M or not M.Parent then return end Touched(z,M)end)Debris:AddItem(z,DisappearTime)z.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(ReloadTime)Tool.Enabled=true end end function Unequipped() end BaseShot=Instance.new("\080\097\114\116")BaseShot.Name="\069\102\102\101\099\116"BaseShot.Color=BulletColor BaseShot.Material=Enum.Material.Plastic BaseShot.TopSurface=Enum.SurfaceType.Smooth BaseShot.BottomSurface=Enum.SurfaceType.Smooth BaseShot.FormFactor=Enum.FormFactor.Custom BaseShot.Size=Vector3.new(5,5,.5)BaseShot.CanCollide=false BaseShot.Locked=true SelectionBoxify(BaseShot)M(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")

BulletSpeed = Handle.BulletSpeed.Value
DisappearTime = Handle.BulletDisappearTime.Value
ReloadTime = Handle.ReloadTime.Value
BulletColor = Handle.BulletColor.Value

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.Color3 = BulletColor
	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 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
					local HitFadeClone = HitFadeSound:Clone()
					HitFadeClone.Parent = torso
					HitFadeClone:Play()
				end
			end
		end
		humanoid.Health -= 10
	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 * BulletSpeed
		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, DisappearTime)
		LaserShotClone.Parent = game:GetService("Workspace")

		wait(0.6) -- FireSound length

		InvokeClient("PlaySound", Sounds.Reload)

		wait(ReloadTime) -- ReloadSound length

		Tool.Enabled = true
	end
end

function Unequipped() end

BaseShot = Instance.new("Part")
BaseShot.Name = "Effect"
BaseShot.Color = BulletColor
BaseShot.Material = Enum.Material.Plastic
BaseShot.TopSurface = Enum.SurfaceType.Smooth
BaseShot.BottomSurface = Enum.SurfaceType.Smooth
BaseShot.FormFactor = Enum.FormFactor.Custom
BaseShot.Size = Vector3.new(5, 5, 0.5)
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)
