Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --https://github.com/Mokiros/roblox-FE-compatibility
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,game,owner = owner,game
- local RealPlayer = Player
- do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end local runDummyScript = function(f,scri)
- local oldenv = getfenv(f)
- local newenv = setmetatable({}, {
- __index = function(_, k)
- if k:lower() == 'script' then
- return scri
- else
- return oldenv[k]
- end
- end
- })
- setfenv(f, newenv)
- ypcall(function() f() end)
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- mas.Name = "CompiledModel"
- o1 = Instance.new("Tool")
- o2 = Instance.new("Part")
- o3 = Instance.new("SpecialMesh")
- o4 = Instance.new("Sound")
- o5 = Instance.new("Sound")
- o6 = Instance.new("Sound")
- o7 = Instance.new("Sound")
- o8 = Instance.new("PointLight")
- o9 = Instance.new("Sound")
- o11 = Instance.new("Animation")
- o12 = Instance.new("ScreenGui")
- o13 = Instance.new("Frame")
- o14 = Instance.new("TextLabel")
- o15 = Instance.new("TextLabel")
- o16 = Instance.new("TextLabel")
- o17 = Instance.new("Frame")
- o18 = Instance.new("Frame")
- o19 = Instance.new("Frame")
- o20 = Instance.new("Frame")
- o21 = Instance.new("ImageLabel")
- o22 = Instance.new("TextLabel")
- o23 = Instance.new("Frame")
- o24 = Instance.new("Frame")
- o25 = Instance.new("TextLabel")
- o26 = Instance.new("LocalScript")
- o27 = Instance.new("LocalScript")
- o28 = Instance.new("LocalScript")
- o29 = Instance.new("Part")
- o30 = Instance.new("SpecialMesh")
- o31 = Instance.new("Part")
- o32 = Instance.new("SpecialMesh")
- o33 = Instance.new("Part")
- o34 = Instance.new("SpecialMesh")
- o35 = Instance.new("Part")
- o36 = Instance.new("SpecialMesh")
- o37 = Instance.new("Part")
- o38 = Instance.new("CylinderMesh")
- o39 = Instance.new("Script")
- o1.Name = "M870"
- o1.Parent = mas
- o1.TextureId = "http://www.roblox.com/asset/?id=122079958"
- o1.GripForward = Vector3.new(-0.242524415, 0.970096886, -0.00969904661)
- o1.GripPos = Vector3.new(0.25999999, -0.600000024, -0.330000013)
- o1.GripRight = Vector3.new(0.970145285, 0.242512301, -0.00242490321)
- o1.GripUp = Vector3.new(2.23517418e-007, 0.00999760628, 0.999950111)
- o1.ToolTip = "Ithaca 37"
- o1.CanBeDropped = false
- o2.Name = "Handle"
- o2.Parent = o1
- o2.BrickColor = BrickColor.new("Black")
- o2.Position = Vector3.new(-72.2855453, 0.500015974, -32.7285843)
- o2.Rotation = Vector3.new(-90, 0, -90)
- o2.FormFactor = Enum.FormFactor.Custom
- o2.Size = Vector3.new(0.200000003, 2.79999995, 1)
- o2.CFrame = CFrame.new(-72.2855453, 0.500015974, -32.7285843, 0, 1, 0, 0, 0, 1, 1, 0, 0)
- o2.BottomSurface = Enum.SurfaceType.Smooth
- o2.TopSurface = Enum.SurfaceType.Smooth
- o2.Color = Color3.new(0.105882, 0.164706, 0.207843)
- o2.Position = Vector3.new(-72.2855453, 0.500015974, -32.7285843)
- o3.Parent = o2
- o3.MeshId = "http://www.roblox.com/asset/?id=71947462"
- o3.Scale = Vector3.new(1.20000005, 1, 1.20000005)
- o3.TextureId = "http://www.roblox.com/asset/?id=71947415"
- o3.MeshType = Enum.MeshType.FileMesh
- o4.Name = "FireSound"
- o4.Parent = o2
- o4.Pitch = 0.94999998807907
- o4.SoundId = "http://roblox.com/asset/?id=130780450 "
- o4.Volume = 1
- o5.Name = "PumpSound"
- o5.Parent = o2
- o5.Pitch = 0.80000001192093
- o5.SoundId = "http://www.roblox.com/asset/?id=10209881"
- o5.Volume = 1
- o6.Name = "Reload"
- o6.Parent = o2
- o6.SoundId = "http://roblox.com/asset/?id=10209845 "
- o6.Volume = 1
- o7.Name = "EquipSound"
- o7.Parent = o2
- o7.SoundId = "http://www.roblox.com/asset/?id=10209881"
- o7.Volume = 1
- o8.Name = "Flash"
- o8.Parent = o2
- o8.Color = Color3.new(1, 1, 0)
- o8.Enabled = false
- o8.Brightness = 1.5
- o9.Name = "Tick"
- o9.Parent = o2
- o9.SoundId = "rbxasset://sounds//clickfast.wav"
- o9.Volume = 1
- o11.Name = "Recoil"
- o11.Parent = o1
- o11.AnimationId = "http://www.roblox.com/Asset?ID=94331086"
- o12.Name = "WeaponHud"
- o12.Parent = o1
- o13.Name = "AmmoHud"
- o13.Parent = o12
- o13.Position = UDim2.new(1,-265,1,-60)
- o13.Size = UDim2.new(0,200,0,50)
- o13.Style = Enum.FrameStyle.RobloxSquare
- o13.Position = UDim2.new(1,-265,1,-60)
- o13.BackgroundTransparency = 1
- o13.BorderSizePixel = 0
- o14.Name = "ForwardSlash"
- o14.Parent = o13
- o14.Position = UDim2.new(0.5,0,0.5,0)
- o14.Text = "/"
- o14.Position = UDim2.new(0.5,0,0.5,0)
- o14.BackgroundTransparency = 1
- o14.BorderSizePixel = 0
- o14.FontSize = Enum.FontSize.Size24
- o14.TextColor3 = Color3.new(1, 1, 1)
- o14.TextStrokeTransparency = 0
- o15.Name = "ClipAmmo"
- o15.Parent = o13
- o15.Position = UDim2.new(0.44999998807907,0,0.5,0)
- o15.Text = "54"
- o15.Position = UDim2.new(0.44999998807907,0,0.5,0)
- o15.BackgroundTransparency = 1
- o15.BorderSizePixel = 0
- o15.FontSize = Enum.FontSize.Size24
- o15.TextColor3 = Color3.new(1, 1, 1)
- o15.TextStrokeTransparency = 0
- o15.TextXAlignment = Enum.TextXAlignment.Right
- o16.Name = "TotalAmmo"
- o16.Parent = o13
- o16.Position = UDim2.new(0.55000001192093,0,0.5,0)
- o16.Text = "180"
- o16.Position = UDim2.new(0.55000001192093,0,0.5,0)
- o16.BackgroundTransparency = 1
- o16.BorderSizePixel = 0
- o16.FontSize = Enum.FontSize.Size24
- o16.TextColor3 = Color3.new(1, 1, 1)
- o16.TextStrokeTransparency = 0
- o16.TextXAlignment = Enum.TextXAlignment.Left
- o17.Name = "Crosshair"
- o17.Parent = o12
- o17.Position = UDim2.new(0,500,0,500)
- o17.Size = UDim2.new(0,150,0,150)
- o17.Position = UDim2.new(0,500,0,500)
- o17.BackgroundColor3 = Color3.new(0, 1, 0)
- o17.BackgroundTransparency = 1
- o17.BorderSizePixel = 0
- o18.Name = "TopFrame"
- o18.Parent = o17
- o18.Position = UDim2.new(0,-1,-0.5,-7)
- o18.Size = UDim2.new(0,2,0,14)
- o18.Position = UDim2.new(0,-1,-0.5,-7)
- o18.BackgroundColor3 = Color3.new(1, 1, 1)
- o18.BorderColor3 = Color3.new(0, 0, 0)
- o19.Name = "RightFrame"
- o19.Parent = o17
- o19.Position = UDim2.new(0.5,-7,0,-1)
- o19.Size = UDim2.new(0,14,0,2)
- o19.Position = UDim2.new(0.5,-7,0,-1)
- o19.BackgroundColor3 = Color3.new(1, 1, 1)
- o19.BorderColor3 = Color3.new(0, 0, 0)
- o20.Name = "LeftFrame"
- o20.Parent = o17
- o20.Position = UDim2.new(-0.5,-7,0,-1)
- o20.Size = UDim2.new(0,14,0,2)
- o20.Position = UDim2.new(-0.5,-7,0,-1)
- o20.BackgroundColor3 = Color3.new(1, 1, 1)
- o20.BorderColor3 = Color3.new(0, 0, 0)
- o21.Name = "TargetHitImage"
- o21.Parent = o17
- o21.Position = UDim2.new(0,-25,0,-25)
- o21.Size = UDim2.new(0,50,0,50)
- o21.Position = UDim2.new(0,-25,0,-25)
- o21.Visible = false
- o21.BackgroundTransparency = 1
- o21.BorderSizePixel = 0
- o21.Image = "http://www.roblox.com/asset/?id=115400215"
- o22.Name = "ReloadingLabel"
- o22.Parent = o17
- o22.Position = UDim2.new(0,20,0,-20)
- o22.Text = "Reloading"
- o22.Position = UDim2.new(0,20,0,-20)
- o22.Visible = false
- o22.BackgroundTransparency = 1
- o22.BorderSizePixel = 0
- o22.Font = Enum.Font.ArialBold
- o22.FontSize = Enum.FontSize.Size18
- o22.TextColor3 = Color3.new(1, 1, 1)
- o22.TextStrokeTransparency = 0
- o22.TextXAlignment = Enum.TextXAlignment.Left
- o22.TextYAlignment = Enum.TextYAlignment.Bottom
- o23.Name = "BottomFrame"
- o23.Parent = o17
- o23.Position = UDim2.new(0,-1,0.5,-7)
- o23.Size = UDim2.new(0,2,0,14)
- o23.Position = UDim2.new(0,-1,0.5,-7)
- o23.BackgroundColor3 = Color3.new(1, 1, 1)
- o23.BorderColor3 = Color3.new(0, 0, 0)
- o24.Name = "Reload"
- o24.Parent = o12
- o24.Position = UDim2.new(1,-265,1,-120)
- o24.Size = UDim2.new(0,200,0,50)
- o24.Position = UDim2.new(1,-265,1,-120)
- o24.Visible = false
- o24.BackgroundTransparency = 1
- o24.BorderSizePixel = 0
- o25.Name = "Reload"
- o25.Parent = o24
- o25.Position = UDim2.new(0.5,0,0.5,0)
- o25.Text = "Press R to Reload"
- o25.Position = UDim2.new(0.5,0,0.5,0)
- o25.BackgroundTransparency = 1
- o25.BorderSizePixel = 0
- o25.Font = Enum.Font.ArialBold
- o25.FontSize = Enum.FontSize.Size24
- o25.TextColor3 = Color3.new(1, 0, 0)
- o25.TextStrokeTransparency = 0
- o26.Name = "Ithaca"
- o26.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- --------------------- TEMPLATE ASSAULT RIFLE WEAPON ---------------------------
- -- Waits for the child of the specified parent
- local function WaitForChild(parent, childName)
- while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
- return parent[childName]
- end
- ----- MAGIC NUMBERS ABOUT THE TOOL -----
- -- How much damage a bullet does
- local Damage = 70
- -- How many times per second the gun can fire
- local FireRate = 1 / 1.33
- -- The maximum distance the can can shoot, this value should never go above 1000
- local Range = 200
- -- In radians the minimum accuracy penalty
- local MinSpread = 0.05
- -- In radian the maximum accuracy penalty
- local MaxSpread = 0.1
- -- Number of bullets in a clip
- local ClipSize = 6
- -- DefaultValue for spare ammo
- local SpareAmmo = 300
- -- The amount the aim will increase or decrease by
- -- decreases this number reduces the speed that recoil takes effect
- local AimInaccuracyStepAmount = 0.0133
- -- Time it takes to reload weapon
- local ReloadTime = 4
- ----------------------------------------
- -- Colors
- local FriendlyReticleColor = Color3.new(0, 1, 0)
- local EnemyReticleColor = Color3.new(1, 0, 0)
- local NeutralReticleColor = Color3.new(1, 1, 1)
- local Spread = MinSpread
- local AmmoInClip = ClipSize
- local Tool = script.Parent
- local Handle = WaitForChild(Tool, 'Handle')
- local WeaponGui = nil
- local LeftButtonDown
- local Reloading = false
- local IsShooting = false
- -- Player specific convenience variables
- local MyPlayer = nil
- local MyCharacter = nil
- local MyHumanoid = nil
- local MyTorso = nil
- local MyMouse = nil
- local RecoilAnim
- local RecoilTrack = nil
- local IconURL = Tool.TextureId -- URL to the weapon icon asset
- local DebrisService = game:GetService('Debris')
- local PlayersService = game:GetService('Players')
- local FireSound
- local OnFireConnection = nil
- local OnReloadConnection = nil
- local DecreasedAimLastShot = false
- local LastSpreadUpdate = time()
- -- this is a dummy object that holds the flash made when the gun is fired
- local FlashHolder = nil
- local WorldToCellFunction = Workspace.Terrain.WorldToCellPreferSolid
- local GetCellFunction = Workspace.Terrain.GetCell
- function RayIgnoreCheck(hit, pos)
- if hit then
- if hit.Transparency >= 1 or string.lower(hit.Name) == "water" or
- hit.Name == "Effect" or hit.Name == "Rocket" or hit.Name == "Bullet" or
- hit.Name == "Handle" or hit:IsDescendantOf(MyCharacter) then
- return true
- elseif hit:IsA('Terrain') and pos then
- local cellPos = WorldToCellFunction(Workspace.Terrain, pos)
- if cellPos then
- local cellMat = GetCellFunction(Workspace.Terrain, cellPos.x, cellPos.y, cellPos.z)
- if cellMat and cellMat == Enum.CellMaterial.Water then
- return true
- end
- end
- end
- end
- return false
- end
- -- @preconditions: vec should be a unit vector, and 0 < rayLength <= 1000
- function RayCast(startPos, vec, rayLength)
- local hitObject, hitPos = game.Workspace:FindPartOnRay(Ray.new(startPos + (vec * .01), vec * rayLength), Handle)
- if hitObject and hitPos then
- local distance = rayLength - (hitPos - startPos).magnitude
- if RayIgnoreCheck(hitObject, hitPos) and distance > 0 then
- -- there is a chance here for potential infinite recursion
- return RayCast(hitPos, vec, distance)
- end
- end
- return hitObject, hitPos
- end
- function TagHumanoid(humanoid, player)
- -- Add more tags here to customize what tags are available.
- while humanoid:FindFirstChild('creator') do
- humanoid:FindFirstChild('creator'):Destroy()
- end
- local creatorTag = Instance.new("ObjectValue")
- creatorTag.Value = player
- creatorTag.Name = "creator"
- creatorTag.Parent = humanoid
- DebrisService:AddItem(creatorTag, 1.5)
- local weaponIconTag = Instance.new("StringValue")
- weaponIconTag.Value = IconURL
- weaponIconTag.Name = "icon"
- weaponIconTag.Parent = creatorTag
- end
- local function CreateBullet(bulletPos)
- local bullet = Instance.new('Part', Workspace)
- bullet.FormFactor = Enum.FormFactor.Custom
- bullet.Size = Vector3.new(0.1, 0.1, 0.1)
- bullet.BrickColor = BrickColor.new("Black")
- bullet.Shape = Enum.PartType.Block
- bullet.CanCollide = false
- bullet.CFrame = CFrame.new(bulletPos)
- bullet.Anchored = true
- bullet.TopSurface = Enum.SurfaceType.Smooth
- bullet.BottomSurface = Enum.SurfaceType.Smooth
- bullet.Name = 'Bullet'
- DebrisService:AddItem(bullet, 2.5)
- return bullet
- end
- local function Reload()
- if not Reloading then
- Reloading = true
- -- Don't reload if you are already full or have no extra ammo
- if AmmoInClip ~= ClipSize and SpareAmmo > 0 then
- if RecoilTrack then
- RecoilTrack:Stop()
- end
- if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
- if WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
- WeaponGui.Crosshair.ReloadingLabel.Visible = true
- end
- end
- script.Parent.Handle.Reload:Play()
- wait(.75)
- script.Parent.Handle.Reload:Play()
- wait(.75)
- script.Parent.Handle.Reload:Play()
- wait(.75)
- script.Parent.Handle.Reload:Play()
- wait(.75)
- script.Parent.Handle.PumpSound:Play()
- -- Only use as much ammo as you have
- local ammoToUse = math.min(ClipSize - AmmoInClip, SpareAmmo)
- AmmoInClip = AmmoInClip + ammoToUse
- SpareAmmo = SpareAmmo - ammoToUse
- UpdateAmmo(AmmoInClip)
- WeaponGui.Reload.Visible = false
- end
- Reloading = false
- end
- end
- function OnFire()
- if IsShooting then return end
- if MyHumanoid and MyHumanoid.Health > 0 then
- if RecoilTrack and AmmoInClip > 0 then
- RecoilTrack:Play()
- end
- IsShooting = true
- while LeftButtonDown and AmmoInClip > 0 and not Reloading do
- if Spread and not DecreasedAimLastShot then
- Spread = math.min(MaxSpread, Spread + AimInaccuracyStepAmount)
- UpdateCrosshair(Spread)
- end
- DecreasedAimLastShot = not DecreasedAimLastShot
- if Handle:FindFirstChild('FireSound') then
- Handle.FireSound:Play()
- Handle.Flash.Enabled = true
- end
- if MyMouse then
- for i = 1,12 do -- Shotgun effect :P
- local targetPoint = MyMouse.Hit.p
- local shootDirection = (targetPoint - Handle.Position).unit
- -- Adjust the shoot direction randomly off by a little bit to account for recoil
- shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
- (0.5 - math.random()) * 2 * Spread,
- (0.5 - math.random()) * 2 * Spread) * shootDirection
- local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
- local bullet
- -- Create a bullet here
- if hitObject then
- bullet = CreateBullet(bulletPos)
- end
- if hitObject and hitObject.Parent then
- local hitHumanoid = hitObject.Parent:FindFirstChild("Humanoid")
- if hitHumanoid then
- local hitPlayer = game.Players:GetPlayerFromCharacter(hitHumanoid.Parent)
- if MyPlayer.Neutral or hitPlayer then
- TagHumanoid(hitHumanoid, MyPlayer)
- hitHumanoid:TakeDamage(Damage)
- if bullet then
- bullet:Destroy()
- bullet = nil
- --bullet.Transparency = 1
- end
- Spawn(UpdateTargetHit)
- elseif not hitPlayer then
- TagHumanoid(hitHumanoid, MyPlayer)
- hitHumanoid:TakeDamage(Damage)
- if bullet then
- bullet:Destroy()
- bullet = nil
- --bullet.Transparency = 1
- end
- Spawn(UpdateTargetHit)
- end
- end
- end
- end
- AmmoInClip = AmmoInClip - 1
- UpdateAmmo(AmmoInClip)
- end
- Handle.PumpSound:Play()
- wait(.2); Handle.Flash.Enabled = false
- wait(FireRate)
- OnMouseUp()
- end
- IsShooting = false
- if AmmoInClip == 0 then
- Handle.Tick:Play()
- WeaponGui.Reload.Visible = true
- end
- if RecoilTrack then
- RecoilTrack:Stop()
- end
- end
- end
- local TargetHits = 0
- function UpdateTargetHit()
- TargetHits = TargetHits + 1
- if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
- WeaponGui.Crosshair.TargetHitImage.Visible = true
- end
- wait(0.5)
- TargetHits = TargetHits - 1
- if TargetHits == 0 and WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
- WeaponGui.Crosshair.TargetHitImage.Visible = false
- end
- end
- function UpdateCrosshair(value, mouse)
- if WeaponGui then
- local absoluteY = 650
- WeaponGui.Crosshair:TweenSize(
- UDim2.new(0, value * absoluteY * 2 + 23, 0, value * absoluteY * 2 + 23),
- Enum.EasingDirection.Out,
- Enum.EasingStyle.Linear,
- 0.33)
- end
- end
- function UpdateAmmo(value)
- if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('ClipAmmo') then
- WeaponGui.AmmoHud.ClipAmmo.Text = AmmoInClip
- if value > 0 and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
- WeaponGui.Crosshair.ReloadingLabel.Visible = false
- end
- end
- if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('TotalAmmo') then
- WeaponGui.AmmoHud.TotalAmmo.Text = SpareAmmo
- end
- end
- function OnMouseDown()
- LeftButtonDown = true
- OnFire()
- end
- function OnMouseUp()
- LeftButtonDown = false
- end
- function OnKeyDown(key)
- if string.lower(key) == 'r' then
- Reload()
- end
- end
- function OnEquipped(mouse)
- Handle.EquipSound:Play()
- RecoilAnim = WaitForChild(Tool, 'Recoil')
- FireSound = WaitForChild(Handle, 'FireSound')
- MyCharacter = Tool.Parent
- MyPlayer = game:GetService('Players'):GetPlayerFromCharacter(MyCharacter)
- MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
- MyTorso = MyCharacter:FindFirstChild('Torso')
- MyMouse = mouse
- WeaponGui = WaitForChild(Tool, 'WeaponHud'):Clone()
- if WeaponGui and MyPlayer then
- WeaponGui.Parent = MyPlayer.PlayerGui
- UpdateAmmo(AmmoInClip)
- end
- if RecoilAnim then
- RecoilTrack = MyHumanoid:LoadAnimation(RecoilAnim)
- end
- if MyMouse then
- -- Disable mouse icon
- MyMouse.Icon = "http://www.roblox.com/asset/?id=18662154"
- MyMouse.Button1Down:connect(OnMouseDown)
- MyMouse.Button1Up:connect(OnMouseUp)
- MyMouse.KeyDown:connect(OnKeyDown)
- end
- end
- -- Unequip logic here
- function OnUnequipped()
- LeftButtonDown = false
- Reloading = false
- MyCharacter = nil
- MyHumanoid = nil
- MyTorso = nil
- MyPlayer = nil
- MyMouse = nil
- if OnFireConnection then
- OnFireConnection:disconnect()
- end
- if OnReloadConnection then
- OnReloadConnection:disconnect()
- end
- if FlashHolder then
- FlashHolder = nil
- end
- if WeaponGui then
- WeaponGui.Parent = nil
- WeaponGui = nil
- end
- if RecoilTrack then
- RecoilTrack:Stop()
- end
- end
- local function SetReticleColor(color)
- if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
- for _, line in pairs(WeaponGui.Crosshair:GetChildren()) do
- if line:IsA('Frame') then
- line.BorderColor3 = color
- end
- end
- end
- end
- Tool.Equipped:connect(OnEquipped)
- Tool.Unequipped:connect(OnUnequipped)
- while true do
- wait(0.033)
- if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and MyMouse then
- WeaponGui.Crosshair.Position = UDim2.new(0, MyMouse.X, 0, MyMouse.Y)
- SetReticleColor(NeutralReticleColor)
- local target = MyMouse.Target
- if target and target.Parent then
- local player = PlayersService:GetPlayerFromCharacter(target.Parent)
- if player then
- if MyPlayer.Neutral or player.TeamColor ~= MyPlayer.TeamColor then
- SetReticleColor(EnemyReticleColor)
- else
- SetReticleColor(FriendlyReticleColor)
- end
- end
- end
- end
- if Spread and not IsShooting then
- local currTime = time()
- if currTime - LastSpreadUpdate > FireRate * 2 then
- LastSpreadUpdate = currTime
- Spread = math.max(MinSpread, Spread - AimInaccuracyStepAmount)
- UpdateCrosshair(Spread, MyMouse)
- end
- end
- end
- end,o26)
- end))
- o27.Name = "ArmWeld [Shotgun]"
- o27.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- Tool = script.Parent;
- local arms = nil
- local torso = nil
- local welds = {}
- function Equip(mouse)
- wait(0.01)
- arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
- torso = Tool.Parent:FindFirstChild("Torso")
- if arms ~= nil and torso ~= nil then
- local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
- if sh ~= nil then
- local yes = true
- if yes then
- yes = false
- sh[1].Part1 = nil
- sh[2].Part1 = nil
- local weld1 = Instance.new("Weld")
- weld1.Part0 = torso
- weld1.Parent = torso
- weld1.Part1 = arms[1]
- weld1.C1 = CFrame.new(-.1, 1.25, .6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(10), math.rad(-90)) ---The first set of numbers changes where the arms move to the second set changes their angles
- welds[1] = weld1
- weld1.Name = "weld1"
- local weld2 = Instance.new("Weld")
- weld2.Part0 = torso
- weld2.Parent = torso
- weld2.Part1 = arms[2]
- weld2.C1 = CFrame.new(-1, -0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0) --- Same as top
- welds[2] = weld2
- weld2.Name = "weld2"
- end
- else
- print("sh")
- end
- else
- print("arms")
- end
- end
- function Unequip(mouse)
- if arms ~= nil and torso ~= nil then
- local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
- if sh ~= nil then
- local yes = true
- if yes then
- yes = false
- sh[1].Part1 = arms[1]
- sh[2].Part1 = arms[2]
- welds[1].Parent = nil
- welds[2].Parent = nil
- end
- else
- print("sh")
- end
- else
- print("arms")
- end
- end
- Tool.Equipped:connect(Equip)
- Tool.Unequipped:connect(Unequip)
- end,o27)
- end))
- o28.Name = "Patrol [Shotgun]"
- o28.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- --Note this must be used with the accompanying weld script
- --This is an edited version of my V3 KeyCommand Script.
- --Heavily edited from a free model crouch script, ~ukwarrior6~
- ----------------------------
- --Patrol Script--
- ----------------------------
- on = 0
- Tool = script.Parent
- welds = {}
- sh = {}
- arms = nil
- torso = nil
- f = nil
- Holstered = false
- wait()
- local Tool = script.Parent
- enabled = true
- ----------------------------------------------------------------------------------------------------------------
- function GunUp()
- Holstered = false
- Tool.Enabled = true
- torso = Tool.Parent:FindFirstChild("Torso")
- if torso ~= nil then
- torso.weld1.C1 = CFrame.new(-.1, 1.25, .6) * CFrame.fromEulerAnglesXYZ(math.rad(290), math.rad(10), math.rad(-90))
- torso.weld2.C1 = CFrame.new(-1, -0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
- end
- end
- function GunDown()
- Holstered = true
- Tool.Enabled = false -- You don't want to be shooting if your not aiming
- torso = Tool.Parent:FindFirstChild("Torso")
- if torso ~= nil then
- torso.weld1.C1 = CFrame.new(-.1, 1.25, .6) * CFrame.fromEulerAnglesXYZ(math.rad(280), math.rad(-10), math.rad(-80))
- torso.weld2.C1 = CFrame.new(-1, -0.2, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-70), math.rad(-25), math.rad(0))
- end
- end
- -----------------------------------------------------------------------------------------------------------------
- function onEquippedLocal(mouse)
- mouse.Icon = "" -- Chuck in a cool crosshair here..
- mouse.KeyDown:connect(onKeyDown)
- end
- -----------------------------------------------------------------------------------------------------------------
- function onKeyDown(key)
- if (key~=nil) then
- key = key:lower()
- if (key=="e") then -- Toggle Patrol
- if Holstered == true then
- script.Parent.Parent.Humanoid.WalkSpeed = 16
- GunUp()
- elseif Holstered == false then
- script.Parent.Parent.Humanoid.WalkSpeed = 20
- GunDown()
- end end end end
- Tool.Equipped:connect(onEquippedLocal)
- end,o28)
- end))
- o29.Name = "12 Gauge Slugs"
- o29.Parent = o1
- o29.BrickColor = BrickColor.new("Medium green")
- o29.Position = Vector3.new(-73.0601883, 0.659587979, -32.8816261)
- o29.Rotation = Vector3.new(-90, 2.45901902e-006, 90)
- o29.Anchored = true
- o29.FormFactor = Enum.FormFactor.Custom
- o29.Size = Vector3.new(0.200000003, 0.200000003, 0.550000191)
- o29.CFrame = CFrame.new(-73.0601883, 0.659587979, -32.8816261, 1.0658141e-014, -1, 4.29179785e-008, 1.44884105e-014, 4.29179714e-008, 1, -1, -4.52982114e-008, -4.37113741e-008)
- o29.BottomSurface = Enum.SurfaceType.Smooth
- o29.TopSurface = Enum.SurfaceType.Smooth
- o29.Color = Color3.new(0.631373, 0.768628, 0.54902)
- o29.Position = Vector3.new(-73.0601883, 0.659587979, -32.8816261)
- o30.Parent = o29
- o30.MeshId = "http://www.roblox.com/asset/?id=94248124"
- o30.TextureId = "http://www.roblox.com/asset/?id=116456647"
- o30.MeshType = Enum.MeshType.FileMesh
- o31.Name = "12 Gauge Slugs"
- o31.Parent = o1
- o31.BrickColor = BrickColor.new("Medium green")
- o31.Position = Vector3.new(-72.7001801, 0.659587979, -32.8816261)
- o31.Rotation = Vector3.new(-90, 2.45901902e-006, 90)
- o31.Anchored = true
- o31.FormFactor = Enum.FormFactor.Custom
- o31.Size = Vector3.new(0.200000003, 0.200000003, 0.550000191)
- o31.CFrame = CFrame.new(-72.7001801, 0.659587979, -32.8816261, 1.0658141e-014, -1, 4.29179785e-008, 1.44884105e-014, 4.29179714e-008, 1, -1, -4.52982114e-008, -4.37113741e-008)
- o31.BottomSurface = Enum.SurfaceType.Smooth
- o31.TopSurface = Enum.SurfaceType.Smooth
- o31.Color = Color3.new(0.631373, 0.768628, 0.54902)
- o31.Position = Vector3.new(-72.7001801, 0.659587979, -32.8816261)
- o32.Parent = o31
- o32.MeshId = "http://www.roblox.com/asset/?id=94248124"
- o32.TextureId = "http://www.roblox.com/asset/?id=116456647"
- o32.MeshType = Enum.MeshType.FileMesh
- o33.Name = "12 Gauge Slugs"
- o33.Parent = o1
- o33.BrickColor = BrickColor.new("Medium green")
- o33.Position = Vector3.new(-72.8801727, 0.659587979, -32.8816261)
- o33.Rotation = Vector3.new(-90, 2.45901902e-006, 90)
- o33.Anchored = true
- o33.FormFactor = Enum.FormFactor.Custom
- o33.Size = Vector3.new(0.200000003, 0.200000003, 0.550000191)
- o33.CFrame = CFrame.new(-72.8801727, 0.659587979, -32.8816261, 1.0658141e-014, -1, 4.29179785e-008, 1.44884105e-014, 4.29179714e-008, 1, -1, -4.52982114e-008, -4.37113741e-008)
- o33.BottomSurface = Enum.SurfaceType.Smooth
- o33.TopSurface = Enum.SurfaceType.Smooth
- o33.Color = Color3.new(0.631373, 0.768628, 0.54902)
- o33.Position = Vector3.new(-72.8801727, 0.659587979, -32.8816261)
- o34.Parent = o33
- o34.MeshId = "http://www.roblox.com/asset/?id=94248124"
- o34.TextureId = "http://www.roblox.com/asset/?id=116456647"
- o34.MeshType = Enum.MeshType.FileMesh
- o35.Name = "12 Gauge Slugs"
- o35.Parent = o1
- o35.BrickColor = BrickColor.new("Medium green")
- o35.Position = Vector3.new(-73.2401886, 0.659588993, -32.8816261)
- o35.Rotation = Vector3.new(-90, 2.45901902e-006, 90)
- o35.Anchored = true
- o35.FormFactor = Enum.FormFactor.Custom
- o35.Size = Vector3.new(0.200000003, 0.200000003, 0.550000191)
- o35.CFrame = CFrame.new(-73.2401886, 0.659588993, -32.8816261, 1.0658141e-014, -1, 4.29179785e-008, 1.44884105e-014, 4.29179714e-008, 1, -1, -4.52982114e-008, -4.37113741e-008)
- o35.BottomSurface = Enum.SurfaceType.Smooth
- o35.TopSurface = Enum.SurfaceType.Smooth
- o35.Color = Color3.new(0.631373, 0.768628, 0.54902)
- o35.Position = Vector3.new(-73.2401886, 0.659588993, -32.8816261)
- o36.Parent = o35
- o36.MeshId = "http://www.roblox.com/asset/?id=94248124"
- o36.TextureId = "http://www.roblox.com/asset/?id=116456647"
- o36.MeshType = Enum.MeshType.FileMesh
- o37.Parent = o1
- o37.BrickColor = BrickColor.new("Really black")
- o37.Position = Vector3.new(-72.967926, 0.740015984, -32.7389069)
- o37.Rotation = Vector3.new(0, 0, 90)
- o37.Anchored = true
- o37.FormFactor = Enum.FormFactor.Symmetric
- o37.Size = Vector3.new(1, 1, 1)
- o37.CFrame = CFrame.new(-72.967926, 0.740015984, -32.7389069, 0, -1, 0, 1, 0, -0, 0, 0, 1)
- o37.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
- o37.Position = Vector3.new(-72.967926, 0.740015984, -32.7389069)
- o38.Parent = o37
- o38.Scale = Vector3.new(0.400000006, 0.699999988, 0.5)
- o39.Name = "Welding"
- o39.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- function Weld(x,y)
- local W = Instance.new("Weld")
- W.Part0 = x
- W.Part1 = y
- local CJ = CFrame.new(x.Position)
- local C0 = x.CFrame:inverse()*CJ
- local C1 = y.CFrame:inverse()*CJ
- W.C0 = C0
- W.C1 = C1
- W.Parent = x
- end
- function Get(A)
- if A.className == "Part" then
- Weld(script.Parent.Handle, A)
- A.Anchored = false
- else
- local C = A:GetChildren()
- for i=1, #C do
- Get(C[i])
- end
- end
- end
- function Finale()
- Get(script.Parent)
- end
- script.Parent.Equipped:connect(Finale)
- script.Parent.Unequipped:connect(Finale)
- Finale()
- end,o39)
- end))
- mas.Parent = workspace
- mas:MakeJoints()
- local mas1 = mas:GetChildren()
- for i=1,#mas1 do
- mas1[i].Parent = game:GetService("Players").LocalPlayer.Backpack
- ypcall(function() mas1[i]:MakeJoints() end)
- end
- mas:Destroy()
- for i=1,#cors do
- coroutine.resume(cors[i])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement