sp=script.Parent firerate=.6 range=950 power=300 rate=.033333333333333 spinuptime=0 barreloffset=Vector3.new(0,0,-1.8)windvec=(Vector3.new(0,-1,1)).unit firetime=0 maxammo=8 reloadtime=.6 ammo=maxammo debris=game:GetService("\068\101\098\114\105\115")equipped=false check=true firing=false reloading=false function wait(o)if o~=nil then local G=0 G=G+(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:wait()while G<o do G=G+(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 waitfor(o,G)while o:FindFirstChild(G)==nil do wait()end return o:FindFirstChild(G)end function checkintangible(o)if o and o~=nil then if o:IsDescendantOf(sp.Parent)or o.Transparency>.8 or o.Name=="\072\097\110\100\108\101"or o.Name=="\069\102\102\101\099\116"or o.Name=="\066\117\108\108\101\116"or o.Name=="\076\097\115\101\114"or string.lower(o.Name)=="\119\097\116\101\114"or o.Name=="\082\097\105\108"or o.Name=="\065\114\114\111\119"then return true end end return false end function castray(o,G,m,O,W)local J,V=game.Workspace:FindPartOnRay(Ray.new(o,G*m),O)if J~=nil then if checkintangible(J)then if W then wait()end J,V=castray(V+G*.01,G,m-(o-V).magnitude,O,W)end end return J,V end function wait(o)if o~=nil then local G=0 G=G+(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:wait()while G<o do G=G+(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(o,G,m,O)local W=(o-G).magnitude local J=Instance.new("\080\097\114\116")J.Name="\069\102\102\101\099\116"J.Anchored=true J.CanCollide=false J.Shape="\066\108\111\099\107"J.formFactor="\067\117\115\116\111\109"J.Size=Vector3.new(.2,.2,.2)J.Transparency=0 J.Material=Enum.Material.SmoothPlastic J.Locked=true J.TopSurface=0 J.BottomSurface=0 J.BrickColor=m J.CFrame=(CFrame.new(G,o)*CFrame.new(0,0,-W/2))*CFrame.Angles(math.pi/2,0,0)local V=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")V.Scale=Vector3.new(1,W*5,1)V.MeshType="\066\114\105\099\107"V.Parent=J debris:AddItem(J,O*.5)J.Parent=game.Workspace wait(.5)J:remove()end function fire()local o=sp.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local G=sp.Parent:FindFirstChild("\072\101\097\100")local m=sp.Parent:FindFirstChild("\084\111\114\115\111")if o and(o.Health>0 and(m and(G and(themouse~=nil and equipped))))then anim2=sp.Parent.Humanoid:LoadAnimation(sp.FireAni)if anim2 then anim2:Play()anim2:AdjustSpeed(1)end local o=G.Position local O=(sp.Handle.CFrame*CFrame.new(barreloffset)).p local W=(themouse.Hit.p-o).unit+Vector3.new(math.random(-1000,1000),math.random(-1000,1000),math.random(-1000,1000))/37500 local J=Instance.new("\080\097\114\116")J.Name="\069\102\102\101\099\116"J.BrickColor=BrickColor.new("\066\108\097\099\107")J.CanCollide=false J.TopSurface="\083\109\111\111\116\104"J.BottomSurface="\083\109\111\111\116\104"J.formFactor="\067\117\115\116\111\109"J.Size=Vector3.new(0,0,0)J.Transparency=1 local V=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")V.Parent=J local r,k=castray(o,W,range,sp.Parent,false)local S=(k-O).unit if r~=nil then local o=(CFrame.new(k,k+S)*CFrame.Angles(math.pi/2,0,0))*CFrame.new(0,0,0)J.CFrame=o local G=Instance.new("\087\101\108\100")G.Part0=r G.Part1=J G.C0=r.CFrame:inverse()*o G.C1=o:inverse()*o G.Parent=J local m=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")m.Name="\099\114\101\097\116\111\114"m.Value=game.Players.LocalPlayer m.Parent=J local O=script.Script:clone()O.Parent=J O.Disabled=false else J.CFrame=CFrame.new(k,k+S)J.Velocity=S*power J.Parent=game.Workspace end debris:AddItem(J,1)J.Parent=game.Workspace delay(0,function()drawbeam(O,k,BrickColor.new("\066\114\105\103\104\116 \121\101\108\108\111\119"),.1)end)local C=sp.Handle:FindFirstChild("\070\105\114\101")if C~=nil then C:Play()end local h=m:FindFirstChild("\082\105\103\104\116 \083\104\111\117\108\100\101\114")if h~=nil then h.CurrentAngle=math.pi/2+.1 end end end function onEquipped(o)equipped=true if o~=nil then anim=sp.Parent.Humanoid:LoadAnimation(sp.idle)if anim then anim:Play()end themouse=o o.Icon="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\092\071\117\110\067\117\114\115\111\114\046\112\110\103"o.Button1Down:connect(function()if sp.Enabled==false then return end sp.Enabled=false if ammo>0 then ammo=ammo-1 fire()fire()fire()fire()fire()fire()fire()fire()fire()fire()else Reload()end o.Icon="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\092\071\117\110\067\117\114\115\111\114\046\112\110\103"Delay(firerate,function()if ammo==0 then Reload()end sp.Enabled=true end)end)o.Button1Up:connect(function()o.Icon="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\092\071\117\110\067\117\114\115\111\114\046\112\110\103"end)o.KeyDown:connect(function(o)if string.lower(o)=="\114"then if ammo~=maxammo and sp.Enabled==true then sp.Enabled=false Reload()sp.Enabled=true end end end)end end function Reload()anim3=sp.Parent.Humanoid:LoadAnimation(sp.Reload)while ammo<maxammo do if anim3 then anim3:Play()anim3:AdjustSpeed(1)end local o=sp.Handle:FindFirstChild("\082\101\108\111\097\100")if o~=nil then o:Play()end wait(reloadtime)ammo=ammo+1 end if anim3 then anim3:Play()anim3:AdjustSpeed(1)end local o=sp.Handle:FindFirstChild("\080\117\109\112")if o~=nil then o:Play()end wait(reloadtime)end function onUnequipped()if anim then anim:Stop()end equipped=false themouse=nil end sp.Equipped:connect(onEquipped)sp.Unequipped:connect(onUnequipped)
--Made by Stickmasterluke

sp = script.Parent

firerate = 0.6
range = 950
power = 300
rate = 1 / 30
spinuptime = 0
barreloffset = Vector3.new(0, 0, -1.8)
windvec = Vector3.new(0, -1, 1).unit
firetime = 0
maxammo = 8
reloadtime = 0.6
ammo = maxammo

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

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 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.SmoothPlastic
	laser.Locked = true
	laser.TopSurface = 0
	laser.BottomSurface = 0
	laser.BrickColor = clr
	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")
	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(1)
		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 * 25))

		local p = Instance.new("Part")
		p.Name = "Effect"
		p.BrickColor = BrickColor.new("Black")
		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

			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 = "rbxasset://textures\\GunCursor.png"
		mouse.Button1Down:connect(function()
			if sp.Enabled == false then
				return
			end
			sp.Enabled = false
			if ammo > 0 then
				ammo = ammo - 1
				fire()
				fire()
				fire()
				fire()
				fire()
				fire()
				fire()
				fire()
				fire()
				fire()
			else
				Reload()
			end
			mouse.Icon = "rbxasset://textures\\GunCursor.png"
			Delay(firerate, function()
				if ammo == 0 then
					Reload()
				end
				sp.Enabled = true
			end)
		end)
		mouse.Button1Up:connect(function()
			mouse.Icon = "rbxasset://textures\\GunCursor.png"
		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()
	anim3 = sp.Parent.Humanoid:LoadAnimation(sp.Reload)
	while ammo < maxammo do
		if anim3 then
			anim3:Play()
			anim3:AdjustSpeed(1)
		end
		local sound = sp.Handle:FindFirstChild("Reload")
		if sound ~= nil then
			sound:Play()
		end
		wait(reloadtime)
		ammo = ammo + 1
	end
	if anim3 then
		anim3:Play()
		anim3:AdjustSpeed(1)
	end
	local sound = sp.Handle:FindFirstChild("Pump")
	if sound ~= nil then
		sound:Play()
	end
	wait(reloadtime)
end

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

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