Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tool = script.Parent
- Handle = Tool:WaitForChild("Handle")
- player = game.Players.LocalPlayer
- --Cursor Icons
- Normal_icon = "http://www.roblox.com/asset/?id=54019936"
- Friend_icon = "http://www.roblox.com/asset/?id=54019944"
- Enemy_icon = "http://www.roblox.com/asset/?id=54019939"
- Reload_icon = "http://www.roblox.com/asset/?id=54020165"
- --Shot settings
- Shot_Color = BrickColor.new("Deep orange")
- mesh_id = ""
- texture_id = ""
- mesh_scale = Vector3.new(0,0,0)
- bullet_spin = Vector3.new(0,0,0)
- --Gun function settings
- Clip_Size = 5
- Fire_Speed = 3
- Reload_Speed = 2
- Automatic = false
- Limited_Weapon = true
- Legendary_Weapon = false
- Weapon_Image = script.Parent.TextureId
- Shots_Per_Bullet = 1
- Inaccuracy = 20
- Distance = 365
- Bullet_Speed = 25
- Bullet_Gravity = 0
- Distance_With_No_Gravity = 0
- Damage = 56
- Head_Damage = 78
- Shoot_From = Vector3.new(0,0,-2) --head
- Shots = game.Workspace:findFirstChild("SHOTS")
- fire_sound = Handle.fire
- reload_sound = Handle.reload
- --Cam settings
- cam = game.Workspace.CurrentCamera
- function GetCamAim()
- return (cam.CoordinateFrame * CFrame.new(0,0,-100)).p
- end
- function CheckIfZoomed()
- local pos = cam.CoordinateFrame
- local head = player.Character:findFirstChild("Head")
- local dist = (pos.p - head.Position).magnitude
- if dist < 3.6 then
- return true
- else
- return false
- end
- end
- shell = Instance.new("Part")
- shell.CanCollide = false
- shell.Name = "beam"
- shell.Anchored = true
- shell.formFactor = "Custom"
- shell.Size = Vector3.new(0.3,3,0.3)
- shell.Reflectance = 0.3
- shell.BrickColor = Shot_Color
- if mesh_id == "" then
- m = Instance.new("BlockMesh",shell)
- m.Scale = Vector3.new(0.3,0.8,0.3)
- else
- m = Instance.new("SpecialMesh",shell)
- m.MeshType = "FileMesh"
- m.Scale = Vector3.new(1,1,1)
- m.MeshId = mesh_id
- m.TextureId = texture_id
- end
- --Shell Settings
- char = player.Character
- is_reloading = false
- last_shot = 0
- fireon = false
- is_reloading = false
- the_clip = Clip_Size
- --GUI
- the_gui = player.PlayerGui:WaitForChild("HUD").gun
- ammtxt = the_gui.mag
- guntxt = the_gui.name
- gunimg = the_gui.gun
- ------------------------------------
- cam = game.Workspace.CurrentCamera
- function GetCamAim()
- return (cam.CoordinateFrame * CFrame.new(0,0,-100)).p
- end
- function CheckIfZoomed()
- local pos = cam.CoordinateFrame
- local head = player.Character:findFirstChild("Head")
- local dist = (pos.p - head.Position).magnitude
- if dist < 3.6 then
- return true
- else
- return false
- end
- end
- shell = Instance.new("Part")
- shell.CanCollide = false
- shell.Name = "beam"
- shell.Anchored = true
- shell.formFactor = "Custom"
- shell.Size = Vector3.new(0.3,3,0.3)
- shell.Reflectance = 0.3
- shell.BrickColor = Shot_Color
- if mesh_id == "" then
- m = Instance.new("BlockMesh",shell)
- m.Scale = Vector3.new(0.3,0.8,0.3)
- else
- m = Instance.new("SpecialMesh",shell)
- m.MeshType = "FileMesh"
- m.Scale = Vector3.new(1,1,1)
- m.MeshId = mesh_id
- m.TextureId = texture_id
- end
- char = player.Character
- is_reloading = false
- last_shot = 0
- fireon = false
- is_reloading = false
- the_clip = Clip_Size
- function GetHumanoid(prt)
- local h1 = prt.Parent:findFirstChild("Zombie")
- local h2 = prt.Parent.Parent:findFirstChild("Zombie")
- if h1 ~= nil then
- return h1
- else
- return h2
- end
- end
- function check_aggressive(cl1,cl2)
- if cl1 == BrickColor.new() or cl2 == BrickColor.new() then
- return true
- end
- local tms = game.Teams
- local alt = tms:findFirstChild("T4V Allies").TeamColor
- local t4vt = tms:findFirstChild("T4V Members").TeamColor
- local ent = tms:findFirstChild("Raiders").TeamColor
- if cl1 == alt or cl1 == t4vt then
- if cl2 == ent then return true end
- else
- if cl1 ~= cl2 then return true end
- end
- return false
- end
- function GetPlayerFromHum(hum)
- pl = game.Players:GetChildren()
- for i = 1,#pl do
- if pl[i].Character:findFirstChild("Humanoid") == hum then
- return pl[i]
- end
- end
- return nil
- end
- function InspectTeam(hum)
- if GetPlayerFromHum(hum) ~= nil then
- return GetPlayerFromHum(hum).TeamColor
- elseif hum.Parent:findFirstChild("AITEAM") ~= nil then
- return hum.Parent:findFirstChild("AITEAM").Value
- else
- return BrickColor.new()
- end
- end
- function GetPosFromHum(hum)
- if hum.Parent:findFirstChild("Torso") ~= nil then
- return hum.Parent:findFirstChild("Torso").Position
- else
- return Vector3.new()
- end
- end
- function MyPos()
- return char.Torso.Position
- end
- function GiveDamage(Hitted_Part,Normal_Damage,HeadShot_Damage)
- local htp = Hitted_Part
- local dmg = Normal_Damage
- local dhm = GetHumanoid(htp)
- if dhm == nil then return end
- if htp.Parent.className == "Hat" or htp.Name == "Head" then
- dmg = HeadShot_Damage
- end
- if dhm then
- local h_team = InspectTeam(dhm)
- if check_aggressive(player.TeamColor,h_team) then
- local tag = Instance.new("ObjectValue")
- tag.Name = "creator"
- tag.Value = player
- local getps = GetPosFromHum(dhm)
- if getps ~= Vector3.new() then
- local psval = Instance.new("IntValue",tag)
- psval.Name = "Distance"
- psval.Value = math.floor((getps-MyPos()).magnitude)
- end
- tag.Parent = dhm
- wait(0.1)
- dhm:TakeDamage(dmg)
- wait(2)
- tag.Parent = nil
- end
- end
- end
- function Run(mouse)
- if is_reloading then
- mouse.Icon = Reload_icon
- return
- end
- mouse.Icon = Normal_icon
- local hit = mouse.Target
- if (hit == nil) then print("") end
- h = GetHumanoid(hit)
- if h ~= nil then
- local torso = hit.Parent.UpperTorso
- if torso ~= nil then
- if h.Health > 0 then
- if check_aggressive(player.TeamColor,InspectTeam(h)) then
- mouse.Icon = Enemy_icon
- else
- mouse.Icon = Friend_icon
- end
- end
- end
- end
- end
- function ShakeCam()
- cam = game.Workspace.CurrentCamera
- local function RandVector()
- return Vector3.new(math.random(-100,100)/40000,math.random(-100,-20)/20000,math.random(-100,100)/40000)
- end
- local function Mult(vct,ml)
- return Vector3.new(vct.x*ml,vct.y*ml,vct.z*ml)
- end
- local tvc = RandVector()
- local tam = math.random(3,3)
- for i = 1,tam do
- cam.CoordinateFrame = cam.CoordinateFrame * CFrame.new(Mult(tvc,math.sin(math.rad((90/tam)*i))))
- wait()
- end
- for i = tam,1,-1 do
- cam.CoordinateFrame = cam.CoordinateFrame * CFrame.new(Mult(-tvc,math.sin(math.rad((90/tam)*i))))
- wait()
- end
- end
- ------------------------------------------------------------------------
- function on(mouse)
- fireon = false
- ammtxt.Text = the_clip .. " / " .. Clip_Size
- guntxt.Text = script.Parent.Name
- if Limited_Weapon == true then
- guntxt.TextColor3 = Color3.new(255, 255, 0)
- guntxt.TextStrokeColor3 = Color3.new(255, 255, 0)
- end
- gunimg.Image = Weapon_Image
- mouse.Button1Down:connect(function()
- fireon = true
- if not Automatic then
- shot()
- end
- end)
- mouse.Button1Up:connect(function()
- fireon = false
- end)
- function onKeyDown(key)
- if (key~=nil) then
- key = key:lower()
- if key == "r" and the_clip < Clip_Size then
- if is_reloading then return end
- ammtxt.Text = "..."
- is_reloading = true
- if reload_sound ~= nil then
- reload_sound:play()
- end
- wait(Reload_Speed)
- the_clip = Clip_Size
- is_reloading = false
- ammtxt.Text = the_clip .. " / " .. Clip_Size
- end
- end
- end
- mouse.KeyDown:connect(onKeyDown)
- function shot()
- if char.Humanoid.Health <= 0 then return end
- if is_reloading then return end
- if tick() - last_shot < Fire_Speed and the_clip > 0 then return end
- if the_clip <= 0 then
- ammtxt.Text = "..."
- is_reloading = true
- if reload_sound ~= nil then
- reload_sound:play()
- end
- wait(Reload_Speed)
- the_clip = Clip_Size
- is_reloading = false
- ammtxt.Text = the_clip .. " / " .. Clip_Size
- else
- script.Parent.Recoil.Value = 6
- last_shot = tick()
- the_clip = the_clip - 1
- ammtxt.Text = the_clip .. " / " .. Clip_Size
- if fire_sound ~= nil then
- fire_sound:play()
- end
- if CheckIfZoomed() then
- PreFire(GetCamAim())
- else
- PreFire(mouse.Hit.p)
- end
- end
- end
- while true do
- wait()
- Run(mouse)
- end
- end
- script.Parent.Unequipped:connect(function()
- fireon = false
- ammtxt.Text = ""
- gunimg.Image = 0
- guntxt.Text = "NO WEAPON EQUIPPED"
- guntxt.TextColor3 = Color3.new(255,0,0)
- guntxt.TextStrokeColor3 = Color3.new(162,0,0)
- end)
- script.Parent.Equipped:connect(on)
- ---------------------------------------
- function raycast(orig33,hitpos33,ignorelist33) --Fire position, Aim Position, Ignored items.
- local origin, frame, ray;
- frame = CFrame.new(orig33, hitpos33)
- ray = Ray.new(frame.p, frame.lookVector * 10)
- local part, hitpos = Workspace:FindPartOnRay(ray, ignorelist33)
- if (part) then
- if part:IsDescendantOf(char) then
- return nil, Vector3.new()
- end
- if part:findFirstChild("Bouncy") ~= nil then
- if part:findFirstChild("Bouncy").ClassName == "BoolValue" then
- if part:findFirstChild("Bouncy").Value then
- return Tool.Handle, Vector3.new()
- end
- end
- end
- if part:findFirstChild("Ignore") ~= nil then
- if part:findFirstChild("Ignore").ClassName == "BoolValue" then
- if part:findFirstChild("Ignore").Value then
- return nil, Vector3.new()
- end
- end
- end
- if part:findFirstChild("Damage") ~= nil then
- local thp = part:findFirstChild("Damage"):findFirstChild("health")
- local ttm = part:findFirstChild("Damage"):findFirstChild("team")
- if part.Damage.ClassName == "BoolValue" and thp ~= nil and ttm ~= nil then
- if part:findFirstChild("Damage").Value and check_aggressive(ttm.Value,player.TeamColor) then
- if Damage > part.Damage:findFirstChild("health").Value then
- part.Damage:findFirstChild("health").Value = 0
- else
- part.Damage:findFirstChild("health").Value = part.Damage:findFirstChild("health").Value - Damage
- end
- return part, hitpos
- end
- end
- end
- return part, hitpos
- else
- return nil, Vector3.new()
- end
- end
- chk = Instance.new("IntValue")
- chk.Value = 0
- fire_at = Vector3.new()
- function PreFire(pss)
- for i = 1,Shots_Per_Bullet do
- fire_at = pss
- chk.Value = chk.Value + 1
- end
- end
- chk.Changed:connect(function()
- Fire(fire_at)
- end)
- chk.Changed:connect(ShakeCam)
- function Fire(aim)
- local shooting_ray = CFrame.new((Tool.Handle.CFrame * CFrame.new(Shoot_From)).p,aim)
- local Gen_Inacc = Vector3.new(math.random(-Inaccuracy*100,Inaccuracy*100)/100,math.random(-Inaccuracy*100,Inaccuracy*100)/100,math.random(-Inaccuracy*100,Inaccuracy*100)/100)
- local shooting_ray2 = CFrame.new(shooting_ray.p,(shooting_ray * CFrame.new(0,0,-100)).p + Gen_Inacc)
- local lazer_start = shooting_ray2 * CFrame.Angles(math.pi / 2, 0, 0)
- ignoreit = Shots
- local i,a,m,hitted
- local p = shell:clone()
- p.Parent = Shots
- p.CFrame = lazer_start
- hitted = nil
- local cnt = 0
- for i = 1,Distance do
- p.CFrame = lazer_start * CFrame.Angles(bullet_spin.x*math.pi,bullet_spin.y*math.pi,bullet_spin.z*math.pi)
- count_start = (lazer_start * CFrame.new(0,-0.8,0)).p
- count_end = (lazer_start * CFrame.new(0,-1,0)).p
- hitted, hpos = raycast(count_start,count_end,ignoreit)
- lazer_start = lazer_start * CFrame.new(0,-1,0)
- if i*Bullet_Speed > Distance_With_No_Gravity then
- if (lazer_start * CFrame.new(0,-1,0)).p.y - lazer_start.p.y > -0.85 then
- lazer_start = lazer_start * CFrame.Angles(math.rad(-0.05*Bullet_Gravity), 0, 0)
- end
- end
- if (hitted) then
- break
- end
- cnt = cnt + 1
- if cnt == Bullet_Speed then
- cnt = 0
- wait()
- end
- end
- p:remove()
- if hitted then
- if not hitted:IsDescendantOf(char) then
- GiveDamage(hitted,Damage,Head_Damage)
- end
- end
- end
- if Automatic then
- while true do
- wait()
- if fireon then
- shot()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment