GroupID=9999 function AntiGH(Q,I)if GH then local Z=game.Players:findFirstChild(Q.Name)local O=game.Players:findFirstChild(I.Name)if Z and O then if Z:IsInGroup(GroupID)and O:IsInGroup(GroupID)then return false end end return true elseif not GH then return true end end MaxDist=1000 function RayCast(Q,I,Z)if WallShoot then ray1=Ray.new(Q,I.unit*999.999)local O,R=Workspace:FindPartOnRay(ray1,Z)ray2=Ray.new(R,I.unit*999.999)local r,v=Workspace:FindPartOnRay(ray2,O)return O,r,v elseif not WallShoot then ray=Ray.new(Q,I.unit*999.999)return Workspace:FindPartOnRay(ray,Z)end end function DmgPlr(Q)if Q~=nil then local I=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")I.Name="\099\114\101\097\116\111\114"I.Value=game.Players:findFirstChild(script.Parent.Parent.Name)local Z=Q.Parent:findFirstChild("\072\117\109\097\110\111\105\100")local O=Q.Parent.Parent:findFirstChild("\072\117\109\097\110\111\105\100")local R=Q.Parent if O~=nil and(R:IsA("\072\097\116")and AntiGH(O.Parent,script.Parent.Parent))then O:TakeDamage(Damage/1)Q.Parent=game.Workspace Q.CFrame=CFrame.new(Q.Position+Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)))R:Remove()I.Parent=O game.Debris:AddItem(I,1.5)elseif Z~=nil and AntiGH(Z.Parent,script.Parent.Parent)then if Q.Name=="\072\101\097\100"then Z:TakeDamage(Damage*1.3)end Z:TakeDamage(Damage)I.Parent=Z game.Debris:AddItem(I,1.5)end end end function onButton1Down(Q)if script.Parent.Ammo.Value==0 then else if GunType==0 then if not enabled then return end enabled=false LaserShoot(Q)if Flash then script.Parent.Barrel.Light.Light.Visible=true end script.Parent.Ammo.Value=script.Parent.Ammo.Value-1 wait(.01)if Flash then script.Parent.Barrel.Light.Light.Visible=false end wait(1/SPS)enabled=true elseif GunType==1 then automatichold=true while automatichold==true and script.Parent.Ammo.Value~=0 do wait()if not enabled then return end if(script.Parent.Parent:findFirstChild("\072\117\109\097\110\111\105\100")).Health==0 then script.Parent:Remove()end enabled=false LaserShoot(Q)if Flash then script.Parent.Barrel.Light.Light.Visible=true end script.Parent.Ammo.Value=script.Parent.Ammo.Value-1 wait(.01)if Flash then script.Parent.Barrel.Light.Light.Visible=false end wait(1/SPS)enabled=true end end end end function LaserShoot(Q)hit=Q.Hit.p local I=script.Parent.Barrel.CFrame.p local Z=(I-hit).magnitude/(Recoil*20)local O=Vector3.new(math.random(-Z,Z),math.random(-Z,Z),math.random(-Z,Z))aim=hit+O local R=Instance.new("\080\097\114\116")R.Name="\066\117\108\108\101\116"R.formFactor=3 R.BrickColor=BrickColor.new(BulletColor)R.Size=Vector3.new(1,1,1)R.Anchored=true R.CanCollide=false R.Transparency=.5 R.Parent=script.Parent.Parent local r=Instance.new("\067\121\108\105\110\100\101\114\077\101\115\104")r.Name="\077\101\115\104"r.Parent=R local v=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")v.Name="\099\114\101\097\116\111\114"v.Value=game.Players:findFirstChild(script.Parent.Parent.Name)pewsound=script:FindFirstChild("\070\105\114\101")if pewsound then pewsound:Play()end local f=script.Parent.Barrel.CFrame.p if WallShoot then local Q,I,Z=RayCast(f,(aim-f).unit*999,script.Parent.Parent)DmgPlr(Q)DmgPlr(I)if Q and I then local Q=(Z-f).magnitude R.CFrame=(CFrame.new(Z,f)*CFrame.new(0,0,-Q/2))*CFrame.Angles(math.rad(90),0,0)r.Scale=Vector3.new(.04,Q,.04)else R.CFrame=(CFrame.new(Z,f)*CFrame.new(0,0,-MaxDist/2))*CFrame.Angles(math.rad(90),0,0)r.Scale=Vector3.new(.04,MaxDist,.04)end elseif not WallShoot then local Q,I=RayCast(f,(aim-f).unit*999,script.Parent.Parent)DmgPlr(Q)if Q then local Q=(I-f).magnitude R.CFrame=(CFrame.new(I,f)*CFrame.new(0,0,-Q/2))*CFrame.Angles(math.rad(90),0,0)r.Scale=Vector3.new(.1,Q,.1)else R.CFrame=(CFrame.new(I,f)*CFrame.new(0,0,-MaxDist/2))*CFrame.Angles(math.rad(90),0,0)r.Scale=Vector3.new(.1,MaxDist,.1)end end game.Debris:AddItem(R,.1)end function onButton1Up(Q)automatichold=false end function onKeyDown(Q,I)if Q:lower()=="\114"then if script.Parent.Ammo.Value~=script.Parent.MaxAmmo.Value then reloadsound=script:FindFirstChild("\082\101\108\111\097\100")if reloadsound then reloadsound:Play()end enabled=false script.Parent.VisibleB.Value=true script.Parent.StringValue.Value="\082\101\108\111\097\100\105\110\103"repeat script.Parent.StringValue.Value="\082\101\108\111\097\100\105\110\103"wait(.15)script.Parent.Ammo.Value=script.Parent.Ammo.Value+3 script.Parent.StringValue.Value="\082\101\108\111\097\100\105\110\103"until script.Parent.Ammo.Value>=script.Parent.MaxAmmo.Value script.Parent.Ammo.Value=script.Parent.MaxAmmo.Value wait(.2)script.Parent.VisibleB.Value=false enabled=true end end if Q:lower()=="\109"then if GunType==1 then GunType=0 Recoil=5 else GunType=1 Recoil=4 end end end function onEquipped(Q)equipped=true if Q==nil then print("\077\111\117\115\101 \110\111\116 \102\111\117\110\100")return end Q.Icon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\050\056\049\050\048\050\057"Q.Button1Down:connect(function()onButton1Down(Q)end)Q.Button1Up:connect(function()onButton1Up(Q)end)Q.KeyDown:connect(function(I)onKeyDown(I,Q)end)end function onUnequipped(Q)equipped=false automatichold=false end script.Parent.Equipped:connect(onEquipped)script.Parent.Unequipped:connect(onUnequipped)while true do wait()if script.Parent.Ammo.Value==0 then script.Parent.VisibleB.Value=true script.Parent.StringValue.Value="\082\101\108\111\097\100"end if GunType==1 then script.Parent.ModeText.Value="\065\117\116\111"else script.Parent.ModeText.Value="\083\101\109\105"end end
--[[local gui = Instance.new("ScreenGui")
local bg = Instance.new("Frame",gui)
local bar = Instance.new("Frame",bg)
local bvl = Instance.new("ImageLabel", bg)
bvl.Name = "Bevel"
bvl.BackgroundTransparency = 1
bvl.Image = "http://www.roblox.com/asset/?id=56852431"
bvl.Size = UDim2.new(1,0,1,0)
bg.Name = "Back"
bar.Name = "Charge"
bar.BackgroundColor3 = Color3.new(200/255,0/255,0/255)
bg.BackgroundColor3 = Color3.new(200/255,200/255,200/255)
bg.Size = UDim2.new(0,10,0,-100)
bg.Position = UDim2.new(0,5,0,500)
bar.Size = UDim2.new(0,4,-1,0)
bar.Position = UDim2.new(0,3,1,0)

ggui = gui:Clone()
ggui.Name = "GunGui"
ggui.Back.Charge.Size = UDim2.new(0,4,-(script.Charge.Value/100),0)]]

GroupID = 9999

function AntiGH(char1, char2)
	if GH then
		local plyr1 = game.Players:findFirstChild(char1.Name)
		local plyr2 = game.Players:findFirstChild(char2.Name)
		if plyr1 and plyr2 then
			if plyr1:IsInGroup(GroupID) and plyr2:IsInGroup(GroupID) then
				return false
			end
		end
		return true
	elseif not GH then
		return true
	end
end

MaxDist = 1000

function RayCast(Start, End, Ignore)
	if WallShoot then
		ray1 = Ray.new(Start, End.unit * 999.999)
		local Part1, TempPos = Workspace:FindPartOnRay(ray1, Ignore)
		ray2 = Ray.new(TempPos, End.unit * 999.999)
		local Part2, EndPos = Workspace:FindPartOnRay(ray2, Part1)
		return Part1, Part2, EndPos
	elseif not WallShoot then
		ray = Ray.new(Start, End.unit * 999.999)
		return Workspace:FindPartOnRay(ray, Ignore)
	end
end

function DmgPlr(Part)
	if Part ~= nil then
		local c = Instance.new("ObjectValue")
		c.Name = "creator"
		c.Value = game.Players:findFirstChild(script.Parent.Parent.Name)
		local hum = Part.Parent:findFirstChild("Humanoid")
		local hathum = Part.Parent.Parent:findFirstChild("Humanoid")
		local hat = Part.Parent
		if hathum ~= nil and hat:IsA("Hat") and AntiGH(hathum.Parent, script.Parent.Parent) then
			hathum:TakeDamage(Damage / 1)
			Part.Parent = game.Workspace
			Part.CFrame =
				CFrame.new(Part.Position + Vector3.new(math.random(-5, 5), math.random(-5, 5), math.random(-5, 5)))
			hat:Remove()
			c.Parent = hathum
			game.Debris:AddItem(c, 1.5)
		elseif hum ~= nil and AntiGH(hum.Parent, script.Parent.Parent) then
			if Part.Name == "Head" then
				hum:TakeDamage(Damage * 1.3)
			end
			hum:TakeDamage(Damage)
			c.Parent = hum
			game.Debris:AddItem(c, 1.5)
		end
	end
end

function onButton1Down(mouse)
	if script.Parent.Ammo.Value == 0 then
	else
		if GunType == 0 then
			if not enabled then
				return
			end
			enabled = false
			LaserShoot(mouse)
			if Flash then
				script.Parent.Barrel.Light.Light.Visible = true
			end
			script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
			wait(0.01)
			if Flash then
				script.Parent.Barrel.Light.Light.Visible = false
			end
			wait(1 / SPS)
			enabled = true
		elseif GunType == 1 then
			automatichold = true
			while automatichold == true and script.Parent.Ammo.Value ~= 0 do
				wait()
				if not enabled then
					return
				end
				if script.Parent.Parent:findFirstChild("Humanoid").Health == 0 then
					script.Parent:Remove()
				end
				enabled = false
				LaserShoot(mouse)
				if Flash then
					script.Parent.Barrel.Light.Light.Visible = true
				end
				script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
				wait(0.01)
				if Flash then
					script.Parent.Barrel.Light.Light.Visible = false
				end
				wait(1 / SPS)
				enabled = true
			end
		end
	end
end

function LaserShoot(mouse)
	hit = mouse.Hit.p
	local StartPos = script.Parent.Barrel.CFrame.p
	local rv = (StartPos - hit).magnitude / (Recoil * 20)
	local rcl = Vector3.new(math.random(-rv, rv), math.random(-rv, rv), math.random(-rv, rv))
	aim = hit + rcl
	local P = Instance.new("Part")
	P.Name = "Bullet"
	P.formFactor = 3
	P.BrickColor = BrickColor.new(BulletColor)
	P.Size = Vector3.new(1, 1, 1)
	P.Anchored = true
	P.CanCollide = false
	P.Transparency = 0.5
	P.Parent = script.Parent.Parent
	local m = Instance.new("CylinderMesh")
	m.Name = "Mesh"
	m.Parent = P
	local c = Instance.new("ObjectValue")
	c.Name = "creator"
	c.Value = game.Players:findFirstChild(script.Parent.Parent.Name)
	pewsound = script:FindFirstChild("Fire")
	if pewsound then
		pewsound:Play()
	end --Brick created. Moving on to next part
	local SPos = script.Parent.Barrel.CFrame.p
	if WallShoot then
		local Part1, Part2, EndPos = RayCast(SPos, (aim - SPos).unit * 999, script.Parent.Parent)
		DmgPlr(Part1)
		DmgPlr(Part2)
		if Part1 and Part2 then
			local enddist = (EndPos - SPos).magnitude
			P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0, 0, -enddist / 2) * CFrame.Angles(math.rad(90), 0, 0)
			m.Scale = Vector3.new(0.04, enddist, 0.04)
		else
			P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0, 0, -MaxDist / 2) * CFrame.Angles(math.rad(90), 0, 0)
			m.Scale = Vector3.new(0.04, MaxDist, 0.04)
		end
	elseif not WallShoot then
		local Part, Pos = RayCast(SPos, (aim - SPos).unit * 999, script.Parent.Parent)
		DmgPlr(Part)
		if Part then
			local dist = (Pos - SPos).magnitude
			P.CFrame = CFrame.new(Pos, SPos) * CFrame.new(0, 0, -dist / 2) * CFrame.Angles(math.rad(90), 0, 0)
			m.Scale = Vector3.new(0.1, dist, 0.1)
		else
			P.CFrame = CFrame.new(Pos, SPos) * CFrame.new(0, 0, -MaxDist / 2) * CFrame.Angles(math.rad(90), 0, 0)
			m.Scale = Vector3.new(0.1, MaxDist, 0.1)
		end
	end
	game.Debris:AddItem(P, 0.1)
end

function onButton1Up(mouse)
	automatichold = false
end

function onKeyDown(key, mouse)
	if key:lower() == "r" then
		if script.Parent.Ammo.Value ~= script.Parent.MaxAmmo.Value then
			reloadsound = script:FindFirstChild("Reload")
			if reloadsound then
				reloadsound:Play()
			end
			enabled = false
			script.Parent.VisibleB.Value = true
			script.Parent.StringValue.Value = "Reloading"
			repeat
				script.Parent.StringValue.Value = "Reloading"
				wait(0.15)
				script.Parent.Ammo.Value = script.Parent.Ammo.Value + 3
				script.Parent.StringValue.Value = "Reloading"
			until script.Parent.Ammo.Value >= script.Parent.MaxAmmo.Value
			script.Parent.Ammo.Value = script.Parent.MaxAmmo.Value
			wait(0.2)
			script.Parent.VisibleB.Value = false
			enabled = true
		end
	end

	if key:lower() == "m" then
		if GunType == 1 then
			GunType = 0
			Recoil = 5
		else
			GunType = 1
			Recoil = 4
		end
	end
end

function onEquipped(mouse)
	equipped = true

	if mouse == nil then
		print("Mouse not found")
		return
	end
	mouse.Icon = "http://www.roblox.com/asset/?id=52812029"
	mouse.Button1Down:connect(function()
		onButton1Down(mouse)
	end)
	mouse.Button1Up:connect(function()
		onButton1Up(mouse)
	end)
	mouse.KeyDown:connect(function(key)
		onKeyDown(key, mouse)
	end)
end

function onUnequipped(mouse)
	equipped = false
	automatichold = false
end

script.Parent.Equipped:connect(onEquipped)
script.Parent.Unequipped:connect(onUnequipped)
while true do
	wait()
	if script.Parent.Ammo.Value == 0 then
		script.Parent.VisibleB.Value = true
		script.Parent.StringValue.Value = "Reload"
	end
	if GunType == 1 then
		script.Parent.ModeText.Value = "Auto"
	else
		script.Parent.ModeText.Value = "Semi"
	end
end
