sp=script.Parent firerate=.075 range=950 power=300 rate=.033333333333333 spinuptime=0 barreloffset=Vector3.new(0,.35,-3.35)windvec=(Vector3.new(2,-1,1)).unit firetime=0 maxammo=400 reloadtime=3.65 ammo=maxammo debris=game:GetService("\068\101\098\114\105\115")equipped=false check=true firing=false reloading=false function waitfor(k,q)while k:FindFirstChild(q)==nil do wait()end return k:FindFirstChild(q)end function checkintangible(k)if k and k~=nil then if k:IsDescendantOf(sp.Parent)or k.Transparency>.8 or k.Name=="\072\097\110\100\108\101"or k.Name=="\069\102\102\101\099\116"or k.Name=="\066\117\108\108\101\116"or k.Name=="\076\097\115\101\114"or string.lower(k.Name)=="\119\097\116\101\114"or k.Name=="\082\097\105\108"or k.Name=="\065\114\114\111\119"then return true end end return false end function castray(k,q,P,L,b)local w,u=game.Workspace:FindPartOnRay(Ray.new(k,q*P),L)if w~=nil then if checkintangible(w)then if b then wait()end w,u=castray(u+q*.01,q,P-(k-u).magnitude,L,b)end end return w,u end function wait(k)if k~=nil then local q=0 q=q+(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:wait()while q<k do q=q+(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:wait()end else(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:wait()end end function drawbeam(k,q,P,L)local b=(k-q).magnitude local w=Instance.new("\080\097\114\116")w.Name="\069\102\102\101\099\116"w.Anchored=true w.CanCollide=false w.Shape="\066\108\111\099\107"w.formFactor="\067\117\115\116\111\109"w.Size=Vector3.new(.2,.2,.2)w.Transparency=0 w.Material=Enum.Material.Neon w.Locked=true w.TopSurface=0 w.BottomSurface=0 w.BrickColor=BrickColor.new("\076\105\109\101 \103\114\101\101\110")w.CFrame=(CFrame.new(q,k)*CFrame.new(0,0,-b/2))*CFrame.Angles(math.pi/2,0,0)local u=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")u.Scale=Vector3.new(1,b*5,1)u.MeshType="\066\114\105\099\107"u.Parent=w debris:AddItem(w,L*.5)w.Parent=game.Workspace wait(.5)w:remove()end function fire()local k=sp.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local q=sp.Parent:FindFirstChild("\072\101\097\100")local P=sp.Parent:FindFirstChild("\084\111\114\115\111")local L=sp.Parent:FindFirstChild("\084\069\065\077")if k and(k.Health>0 and(P and(q and(themouse~=nil and equipped))))then anim2=sp.Parent.Humanoid:LoadAnimation(sp.FireAni)if anim2 then anim2:Play()anim2:AdjustSpeed(5)end local k=q.Position local b=(sp.Handle.CFrame*CFrame.new(barreloffset)).p local w=(themouse.Hit.p-k).unit+Vector3.new(math.random(-1000,1000),math.random(-1000,1000),math.random(-1000,1000))/56250.0 local u=Instance.new("\080\097\114\116")u.Name="\069\102\102\101\099\116"u.BrickColor=BrickColor.new("\076\105\109\101 \103\114\101\101\110")u.CanCollide=false u.TopSurface="\083\109\111\111\116\104"u.BottomSurface="\083\109\111\111\116\104"u.formFactor="\067\117\115\116\111\109"u.Size=Vector3.new(0,0,0)u.Transparency=1 local C=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")C.Parent=u local B,h=castray(k,w,range,sp.Parent,false)local f=(h-b).unit if B~=nil then local k=(CFrame.new(h,h+f)*CFrame.Angles(math.pi/2,0,0))*CFrame.new(0,0,0)u.CFrame=k local q=Instance.new("\087\101\108\100")q.Part0=B q.Part1=u q.C0=B.CFrame:inverse()*k q.C1=k:inverse()*k q.Parent=u;(L:clone()).Parent=u 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=game.Players.LocalPlayer P.Parent=u local b=script.Script:clone()b.Parent=u b.Disabled=false else u.CFrame=CFrame.new(h,h+f)u.Velocity=f*power u.Parent=game.Workspace end debris:AddItem(u,1)u.Parent=game.Workspace delay(0,function()drawbeam(b,h,BrickColor.new("\066\114\105\103\104\116 \121\101\108\108\111\119"),.1)end)local s=P:FindFirstChild("\082\105\103\104\116 \083\104\111\117\108\100\101\114")if s~=nil then s.CurrentAngle=math.pi/2+.1 end end end function onEquipped(k)equipped=true if k~=nil then anim=sp.Parent.Humanoid:LoadAnimation(sp.idle)if anim then anim:Play()end themouse=k k.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\050\057\054\054\048\049\050"k.Button1Down:connect(function()k.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\050\057\054\054\048\049\050"firetime=tick()+spinuptime down=true end)k.Button1Up:connect(function()down=false k.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\050\057\054\054\048\049\050"end)k.KeyDown:connect(function(k)if string.lower(k)=="\114"then if ammo~=maxammo and sp.Enabled==true then sp.Enabled=false Reload()sp.Enabled=true end end end)end end function Reload()sp.Handle.Fire:Stop()anim3=sp.Parent.Humanoid:LoadAnimation(sp.Reload)if anim3 then anim3:Play()anim3:AdjustSpeed(2.5)end local k=sp.Handle:FindFirstChild("\082\101\108\111\097\100")if k~=nil then k:Play()end wait(reloadtime)ammo=maxammo end function onUnequipped()if anim then anim:Stop()end equipped=false themouse=nil end sp.Equipped:connect(onEquipped)sp.Unequipped:connect(onUnequipped)while true do if down and(equipped and sp.Enabled==true)then sp.Enabled=false if ammo>0 then ammo=ammo-1 if sp.Handle.Fire.IsPlaying==false then sp.Handle.Fire:Play()end fire()wait(firerate)else Reload()end sp.Enabled=true else sp.Handle.Fire:Stop()wait()end end
--Made by Stickmasterluke

sp = script.Parent

firerate = 0.075
range = 950
power = 300
rate = 1 / 30
spinuptime = 0
barreloffset = Vector3.new(0, 0.35, -3.35)
windvec = Vector3.new(2, -1, 1).unit
firetime = 0
maxammo = 400
reloadtime = 3.65
ammo = maxammo

debris = game:GetService("Debris")
equipped = false
check = true
firing = false
reloading = false

function waitfor(parent, name)
	while parent:FindFirstChild(name) == nil do
		wait()
	end
	return parent:FindFirstChild(name)
end

function checkintangible(hit)
	if hit and hit ~= nil then
		if
			hit:IsDescendantOf(sp.Parent)
			or hit.Transparency > 0.8
			or hit.Name == "Handle"
			or hit.Name == "Effect"
			or hit.Name == "Bullet"
			or hit.Name == "Laser"
			or string.lower(hit.Name) == "water"
			or hit.Name == "Rail"
			or hit.Name == "Arrow"
		then
			return true
		end
	end
	return false
end

function castray(startpos, vec, length, ignore, delayifhit)
	local hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore)
	if hit ~= nil then
		if checkintangible(hit) then
			if delayifhit then
				wait()
			end
			hit, endpos2 =
				castray(endpos2 + (vec * 0.01), vec, length - (startpos - endpos2).magnitude, ignore, delayifhit)
		end
	end
	return hit, endpos2
end

function wait(TimeToWait)
	if TimeToWait ~= nil then
		local TotalTime = 0
		TotalTime = TotalTime + game:GetService("RunService").Heartbeat:wait()
		while TotalTime < TimeToWait do
			TotalTime = TotalTime + game:GetService("RunService").Heartbeat:wait()
		end
	else
		game:GetService("RunService").Heartbeat:wait()
	end
end

function drawbeam(beamstart, beamend, clr, fadedelay)
	local dist = (beamstart - beamend).magnitude
	local laser = Instance.new("Part")
	laser.Name = "Effect"
	laser.Anchored = true
	laser.CanCollide = false
	laser.Shape = "Block"
	laser.formFactor = "Custom"
	laser.Size = Vector3.new(0.2, 0.2, 0.2)
	laser.Transparency = 0
	laser.Material = Enum.Material.Neon
	laser.Locked = true
	laser.TopSurface = 0
	laser.BottomSurface = 0
	laser.BrickColor = BrickColor.new("Lime green")
	laser.CFrame = CFrame.new(beamend, beamstart) * CFrame.new(0, 0, -dist / 2) * CFrame.Angles(math.pi / 2, 0, 0)
	local m = Instance.new("SpecialMesh")
	m.Scale = Vector3.new(1, dist * 5, 1)
	m.MeshType = "Brick"
	m.Parent = laser
	debris:AddItem(laser, fadedelay * 0.5)
	laser.Parent = game.Workspace

	--[[local frames=math.floor(fadedelay/rate)
	for frame=1,frames do
		wait(rate)
		local percent=frame/frames
		laser.CFrame=laser.CFrame+windvec*rate
		laser.Transparency=.5+(percent*.5)
	end]]
	wait(0.5)
	laser:remove()
end

function fire()
	local hu = sp.Parent:FindFirstChild("Humanoid")
	local he = sp.Parent:FindFirstChild("Head")
	local t = sp.Parent:FindFirstChild("Torso")
	local team = sp.Parent:FindFirstChild("TEAM")
	if hu and hu.Health > 0 and t and he and themouse ~= nil and equipped then
		anim2 = sp.Parent.Humanoid:LoadAnimation(sp.FireAni)
		if anim2 then
			anim2:Play()
			anim2:AdjustSpeed(5)
		end
		local startpos = he.Position
		local fakestartpos = (sp.Handle.CFrame * CFrame.new(barreloffset)).p
		local vec = (themouse.Hit.p - startpos).unit
			+ (
				Vector3.new(math.random(-1000, 1000), math.random(-1000, 1000), math.random(-1000, 1000)) / (
					1500 * 37.5
				)
			)

		local p = Instance.new("Part")
		p.Name = "Effect"
		p.BrickColor = BrickColor.new("Lime green")
		p.CanCollide = false
		p.TopSurface = "Smooth"
		p.BottomSurface = "Smooth"
		p.formFactor = "Custom"
		p.Size = Vector3.new(0, 0, 0)
		p.Transparency = 1
		local m = Instance.new("SpecialMesh")
		m.Parent = p

		local hit, endpos = castray(startpos, vec, range, sp.Parent, false)
		local fakevec = (endpos - fakestartpos).unit
		if hit ~= nil then
			local newcf = CFrame.new(endpos, endpos + fakevec) * CFrame.Angles(math.pi / 2, 0, 0) * CFrame.new(0, 0, 0)
			p.CFrame = newcf
			local w = Instance.new("Weld")
			w.Part0 = hit
			w.Part1 = p
			w.C0 = hit.CFrame:inverse() * newcf
			w.C1 = newcf:inverse() * newcf
			w.Parent = p

			team:clone().Parent = p

			local c = Instance.new("ObjectValue")
			c.Name = "creator"
			c.Value = game.Players.LocalPlayer
			c.Parent = p

			local s = script.Script:clone()
			s.Parent = p
			s.Disabled = false
		else
			p.CFrame = CFrame.new(endpos, endpos + fakevec)
			p.Velocity = fakevec * power
			p.Parent = game.Workspace
		end

		debris:AddItem(p, 1)
		p.Parent = game.Workspace

		delay(0, function()
			drawbeam(fakestartpos, endpos, BrickColor.new("Bright yellow"), 0.1)
		end)

		--[[local sound=sp.Handle:FindFirstChild("Fire")
		if sound~=nil then
			--sound:Stop()
			sound:Play()
		end]]

		local shoulder = t:FindFirstChild("Right Shoulder")
		if shoulder ~= nil then
			shoulder.CurrentAngle = (math.pi / 2) + 0.1
		end
	end
end

function onEquipped(mouse)
	equipped = true
	if mouse ~= nil then
		anim = sp.Parent.Humanoid:LoadAnimation(sp.idle)
		if anim then
			anim:Play()
		end
		themouse = mouse
		mouse.Icon = "http://www.roblox.com/asset/?id=2966012"
		mouse.Button1Down:connect(function()
			mouse.Icon = "http://www.roblox.com/asset/?id=2966012"
			firetime = tick() + spinuptime
			down = true
		end)
		mouse.Button1Up:connect(function()
			down = false
			mouse.Icon = "http://www.roblox.com/asset/?id=2966012"
		end)
		mouse.KeyDown:connect(function(Key)
			if string.lower(Key) == "r" then
				if ammo ~= maxammo and sp.Enabled == true then
					sp.Enabled = false
					Reload()
					sp.Enabled = true
				end
			end
		end)
	end
end

function Reload()
	sp.Handle.Fire:Stop()
	anim3 = sp.Parent.Humanoid:LoadAnimation(sp.Reload)
	if anim3 then
		anim3:Play()
		anim3:AdjustSpeed(2.5)
	end
	local sound = sp.Handle:FindFirstChild("Reload")
	if sound ~= nil then
		sound:Play()
	end
	wait(reloadtime)
	ammo = maxammo
end

function onUnequipped()
	if anim then
		anim:Stop()
	end
	equipped = false
	themouse = nil
end

sp.Equipped:connect(onEquipped)
sp.Unequipped:connect(onUnequipped)

while true do
	if down and equipped and sp.Enabled == true then
		sp.Enabled = false
		if ammo > 0 then
			ammo = ammo - 1
			if sp.Handle.Fire.IsPlaying == false then
				sp.Handle.Fire:Play()
			end
			fire()
			wait(firerate)
		else
			Reload()
		end
		sp.Enabled = true
	else
		sp.Handle.Fire:Stop()
		wait()
	end
end
