Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Converted with ttyyuu12345's model to script plugin v4
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- Part1 = Instance.new("Part")
- LocalScript2 = Instance.new("LocalScript")
- SpecialMesh3 = Instance.new("SpecialMesh")
- PointLight4 = Instance.new("PointLight")
- PointLight5 = Instance.new("PointLight")
- SpotLight6 = Instance.new("SpotLight")
- Sound7 = Instance.new("Sound")
- Part8 = Instance.new("Part")
- SpecialMesh9 = Instance.new("SpecialMesh")
- Weld10 = Instance.new("Weld")
- Script11 = Instance.new("Script")
- Tool0.Name = "TommyGun"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset/?id=116747513"
- Tool0.GripForward = Vector3.new(-0.342020124, -0.734681308, -0.585888743)
- Tool0.GripPos = Vector3.new(0, -0.600000024, 0.5)
- Tool0.GripRight = Vector3.new(0.938404799, -0.234404698, -0.253871709)
- Tool0.GripUp = Vector3.new(-0.0491797142, 0.636630058, -0.769599557)
- Tool0.ToolTip = "nigger nigger nigger"
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.Rotation = Vector3.new(90, -65.9399948, 90)
- Part1.FormFactor = Enum.FormFactor.Custom
- Part1.Size = Vector3.new(0.540003419, 1.26000023, 4.10998917)
- Part1.CFrame = CFrame.new(0.612733841, 32.6300011, -45.7190094, 2.7213483e-08, -0.407661706, -0.913133502, 1.21492656e-08, 0.913132966, -0.407661796, 1.0000006, 0, 2.98023224e-08)
- Part1.Position = Vector3.new(0.612733841, 32.6300011, -45.7190094)
- Part1.Orientation = Vector3.new(24.0599995, -90, 0)
- LocalScript2.Parent = Part1
- table.insert(cors,sandbox(LocalScript2,function()
- ------------------------
- --[[UTIL Functions]]--
- ------------------------
- --Global functions used by all classes are wrapped in UTIL
- --deal with it.
- local UTIL = {}
- function UTIL.Class(tableIn,template)
- tableIn = tableIn or {}
- local mt = {
- __metatable = UTIL.DeepCopy(template);
- __index = UTIL.DeepCopy(template);
- }
- return setmetatable(tableIn, mt)
- end
- function UTIL.MakeClass(...)
- local arg = {...}
- assert(#arg>0, 'ERROR: class needs 1 argument or more')
- local members = arg[1]
- for i=2,#arg,1 do
- if type(arg[i])=='table' then
- for key,val in pairs(arg[i]) do
- if not members[key] then
- members[key] = val
- end
- end
- end
- end
- local function New(init)
- return UTIL.Class(init or {},members)
- end
- local function Copy(obj, ...)
- local newobj = obj:New(unpack(arg))
- for n,v in pairs(obj) do newobj[n] = v end
- return newobj
- end
- members.New = New
- members.Copy = Copy
- return mt
- end
- function UTIL.DeepCopy(orig)
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in next, orig, nil do
- copy[UTIL.DeepCopy(orig_key)] = UTIL.DeepCopy(orig_value)
- end
- setmetatable(copy, UTIL.DeepCopy(getmetatable(orig)))
- else -- number, string, boolean, etc
- copy = orig
- end
- return copy
- end
- function UTIL.Instantiate(guiType)
- return function(data)
- local obj = Instance.new(guiType)
- for k, v in pairs(data) do
- if type(k) == 'number' then
- v.Parent = obj
- else
- obj[k] = v
- end
- end
- return obj
- end
- end
- function UTIL.RetroRegister(func,...)
- func()
- for _,i in ipairs({...}) do
- i:connect(func)
- end
- end
- -- Waits for a new character to be added if the current one is invalid
- -- (Ensures that you don't have the old dead character after a respawn)
- function UTIL.WaitForValidCharacter(player)
- local character = player.Character
- if not character or not character.Parent or not character:FindFirstChild('Humanoid') or character.Humanoid.Health <= 0 then
- player.CharacterAdded:wait()
- wait(0) --NOTE: Necessary for server scripts executing on the same event
- character = player.Character
- end
- return character
- end
- -- Returns a character ancestor and its Humanoid, or nil
- function UTIL.FindCharacterAncestor(subject)
- if subject and subject ~= Workspace then
- local humanoid = subject:FindFirstChild('Humanoid')
- if humanoid then
- return subject, humanoid
- else
- return UTIL.FindCharacterAncestor(subject.Parent)
- end
- end
- return nil
- end
- UTIL.AssetURL = 'http://www.roblox.com/asset/?id='
- UTIL.TouchEnabled = game:GetService("UserInputService").TouchEnabled
- do
- local suceeded,_ =pcall(function() game.Workspace.CurrentCamera:GetPanSpeed() end)
- UTIL.CanCheckPanSpeed = suceeded
- end
- local DebrisService = Game:GetService('Debris')
- local DebugPrintOffset = 0
- function UTIL.Dprint(...)
- local line = ''
- for _, segment in pairs({...}) do
- line = line .. (line and ' ' or '') .. tostring(segment)
- end
- local gui = Instance.new('ScreenGui')
- local label = Instance.new('TextLabel')
- label.Text = line
- label.Size = UDim2.new(0.25, 0, 0.05, 0)
- label.BackgroundTransparency = 0.5
- label.Position = UDim2.new(0, 0, 0, DebugPrintOffset)
- label.TextWrapped = true
- label.Parent = gui
- DebrisService:AddItem(gui, 30)
- gui.Parent = script.Parent
- DebugPrintOffset = (DebugPrintOffset <= 600) and DebugPrintOffset + 30 or 0
- end
- --
- --All Welding Related Utility functions should be put here
- --
- WeldUtil = {}
- do
- function WeldUtil:WeldBetween(a, b)
- local weld = Instance.new("Weld")
- weld.Part0 = a
- weld.Part1 = b
- weld.C0 = CFrame.new()
- weld.C1 = b.CFrame:inverse() * a.CFrame
- weld.Parent = a
- return weld
- end
- function WeldUtil:PermaWeld(weld)
- local OriginalParent = weld.Parent
- weld.Changed:connect(function()
- Delay(0,function() weld.Parent = OriginalParent end)
- end)
- end
- end
- local InternalEvent =
- {
- Listeners = nil,
- }
- do
- UTIL.MakeClass(InternalEvent)
- function InternalEvent:Connect(func)
- if not self.Listeners then self.Listeners = {} end
- table.insert(self.Listeners,func)
- end
- function InternalEvent:Fire(...)
- if not self.Listeners then return end
- local args = {...}
- for _,i in ipairs(self.Listeners) do
- Spawn(function() i(unpack(args)) end)
- end
- end
- end
- local PartProjectile =
- {
- Damage = 5, -- Base output damage per shot.
- Range = 250, -- Max distance that the weapon can fire.
- Speed = 1,--how many studs per second to move
- DirectionRay=nil,
- Part = nil,
- IsAlive = true,
- IgnoreList = {},
- }
- do
- UTIL.MakeClass(PartProjectile)
- function PartProjectile.New(base,ray)
- local init = nil
- --if base is a copy of this class, then copy over fields
- if type(base) == 'table' and base.Update then
- init = UTIL.DeepCopy(base)
- init.Part= base.Part:Clone()
- else
- init = UTIL.DeepCopy(PartProjectile)
- init.Part = base:Clone()
- end
- init.Part.CFrame = CFrame.new(ray.Origin,ray.Origin+ray.Direction)
- init.Part.Parent = game.Workspace
- init.DirectionRay = ray
- table.insert(init.IgnoreList,init.Part)
- return init
- end
- function PartProjectile:Hit(part)
- local char,hum = UTIL.FindCharacterAncestor(part)
- if hum then
- hum:TakeDamage(self.Damage)
- end
- self.IsAlive = false
- end
- function PartProjectile:Update(dt)
- if not self.IsAlive then return end
- local oldPos = self.Part.CFrame
- self.Part.CFrame = oldPos+(self.DirectionRay.Direction*self.Speed*dt)
- if (self.Part.CFrame.p-self.DirectionRay.Origin).magnitude>self.Range then
- self.IsAlive = false
- end
- local obj = game.Workspace:FindPartOnRayWithIgnoreList( Ray.new(oldPos.p,self.DirectionRay.Direction*self.Speed*dt), self.IgnoreList,false )
- if obj then
- self:Hit(obj)
- end
- end
- function PartProjectile:Destroy()
- self.Part.Parent = nil
- end
- end
- --[[shooting Tool Class]]--
- local ShootingTool =
- {
- FireRate = .5, -- How often the weapon can fire.
- Automatic = false, -- hold down to continue firing
- Spread = 0, -- The bigger the spread, the more inaccurate the shots will be.
- ClipSize = 50, -- Shots in a clip
- ReloadTime = 3, -- Time it takes to reload the tool.
- StartingClips = -1,
- BarrelPos = CFrame.new(0, 0, - 1.2), -- L, F, U
- SourcePart = nil,
- TemplateProjectile = nil,
- Projectiles = {},
- IsFireing = false,
- OnFire = nil,
- OnReload = nil,
- BulletsLeft = 50,
- LastReload = 0,
- FireSound = nil,
- }
- do
- UTIL.MakeClass(ShootingTool)
- function ShootingTool.New(nSource,nProjectile)
- local init= UTIL.DeepCopy(ShootingTool)
- init.SourcePart= nSource
- init.TemplateProjectile = nProjectile
- init.OnFire = InternalEvent.New()
- init.OnReload = InternalEvent.New()
- return init
- end
- function ShootingTool:UpdateBullets(dt)
- for index,i in ipairs(self.Projectiles) do
- if i.IsAlive then
- i:Update(dt)
- else
- i:Destroy()
- table.remove(self.Projectiles, index)
- end
- end
- end
- function ShootingTool:StartFireing(mouse)
- if tick()-self.LastReload<self.ReloadTime then return end
- while self.IsFireing do wait() end
- self.IsFireing = true
- repeat
- if tick()-self.LastReload>self.ReloadTime then
- local startPos = self.SourcePart.CFrame:toWorldSpace(self.BarrelPos)
- local dir = (CFrame.Angles((math.random()-.5)*2*self.Spread,(math.random()-.5)*2*self.Spread,(math.random()-.5)*2*self.Spread)*CFrame.new((mouse.Hit.p-startPos.p).unit)).p
- local nprojectile = PartProjectile.New(self.TemplateProjectile, Ray.new(startPos.p,dir))
- table.insert(self.Projectiles,nprojectile)
- self.OnFire:Fire()
- if self.FireSound then
- self.FireSound:Play()
- end
- self.BulletsLeft = self.BulletsLeft -1
- end
- if self.BulletsLeft==0 then
- self.OnReload:Fire()
- self.BulletsLeft = self.ClipSize
- self.LastReload = tick()
- end
- wait(self.FireRate)
- until not self.IsFireing or not self.Automatic
- end
- function ShootingTool:EndFireing()
- self.IsFireing=false
- end
- end
- do
- local Handle = script.Parent
- local Tool = Handle.Parent
- local BarrelClip = UTIL.Instantiate"Part"
- {
- Size = Vector3.new(0.2, 0.2, 0.32),
- UTIL.Instantiate'SpecialMesh'
- {
- TextureId = "http://www.roblox.com/asset/?id=116679995",
- MeshId = "http://www.roblox.com/asset/?id=116740155",
- Scale = Vector3.new(0.9, 0.9, 0.9),
- },
- CanCollide = false,
- Parent = Tool
- }
- local BarrelWeld = UTIL.Instantiate"Weld"
- {
- C1 = CFrame.new(0.0183372498, 0.378660202, 0.237049103, 0.00777955074, 0.0069010579, 0.999946177, -0.0223222617, 0.999727845, -0.00672559161, -0.999720693, -0.0222686939, 0.00793197285),
- C0 = CFrame.new(0, 0, 0, 0.00777955074, 0.0069010579, 0.999946177, -0.0223222617, 0.999727845, -0.00672559161, -0.999720693, -0.0222686939, 0.00793197285),
- Part0 = Handle,
- Part1 = BarrelClip,
- Parent = Handle,
- }
- WeldUtil:PermaWeld(BarrelWeld)
- local OrangeLight = Handle:WaitForChild('OrangeLight')
- local RedLight = Handle:WaitForChild('RedLight')
- local SpotLight = Handle:WaitForChild('SpotLight')
- local Player = game.Players.LocalPlayer
- local Character = UTIL.WaitForValidCharacter(Player)
- local HoldAni = UTIL.Instantiate"Animation"
- {AnimationId = "http://www.roblox.com/Asset?ID=116690317"}
- local ReloadAni = UTIL.Instantiate"Animation"
- {AnimationId = "http://www.roblox.com/Asset?ID=116695140"}
- local HoldAniTrack
- local ReloadAniTrack
- local ShellMesh = UTIL.Instantiate"SpecialMesh"
- {
- MeshId = UTIL.AssetURL..94295100,--116680945,
- TextureId = UTIL.AssetURL..94287792,--116681256,
- Scale = Vector3.new(2.8,2.8,5),
- }
- local Projectile
- do
- local tpart = UTIL.Instantiate"Part"
- {
- Anchored = true,
- CanCollide = false,
- Size = Vector3.new(.2,.2,.6),
- ShellMesh:Clone(),
- }
- Projectile = PartProjectile.New(tpart,Ray.new())
- end
- table.insert(Projectile.IgnoreList,Handle)
- Projectile.Speed = 200
- local Gun = ShootingTool.New(Handle,Projectile)
- Gun.Automatic = true
- Gun.BarrelPos = CFrame.new(0, 0, - 3.1)
- Gun.FireRate = .05
- Gun.Spread = .1
- Gun.FireSound = Handle:WaitForChild('FireSound')
- Gun.OnFire:Connect(function()
- SpotLight.Enabled = true
- if(math.random()>.5) then
- OrangeLight.Enabled =true
- else
- RedLight.Enabled =true
- end
- wait(.05)
- SpotLight.Enabled = false
- OrangeLight.Enabled =false
- RedLight.Enabled =false
- end)
- Gun.OnReload:Connect(function()
- local leftArm = Character:FindFirstChild('Left Arm')
- if not leftArm then return end
- local reloadBarrel = BarrelClip:Clone()
- reloadBarrel.Parent = Tool
- local tweld=WeldUtil:WeldBetween(reloadBarrel,leftArm)
- BarrelClip.Transparency = 1
- if ReloadAniTrack then
- ReloadAniTrack:Play()
- end
- wait(3)
- reloadBarrel:Destroy()
- tweld:Destroy()
- BarrelClip.Transparency = 0
- end)
- Tool.Equipped:connect(function(mouse)
- Character = UTIL.WaitForValidCharacter(Player)
- local Humanoid = Character:FindFirstChild('Humanoid')
- table.insert(Projectile.IgnoreList,Character)
- HoldAniTrack = Humanoid:LoadAnimation(HoldAni)
- ReloadAniTrack = Humanoid:LoadAnimation(ReloadAni)
- HoldAniTrack:Play()
- mouse.Button1Down:connect(function()
- Gun:StartFireing(mouse)
- end)
- mouse.Button1Up:connect(function()
- Gun:EndFireing()
- end)
- end)
- Tool.Unequipped:connect(function()
- HoldAniTrack:Stop()
- end)
- while true do
- Gun:UpdateBullets(1/30)
- wait()
- end
- end
- end))
- SpecialMesh3.Parent = Part1
- SpecialMesh3.MeshId = "http://www.roblox.com/asset/?id=116679805"
- SpecialMesh3.Scale = Vector3.new(0.899999976, 0.899999976, 0.899999976)
- SpecialMesh3.TextureId = "http://www.roblox.com/asset/?id=116679995"
- SpecialMesh3.MeshType = Enum.MeshType.FileMesh
- SpecialMesh3.Scale = Vector3.new(0.899999976, 0.899999976, 0.899999976)
- PointLight4.Name = "OrangeLight"
- PointLight4.Parent = Part1
- PointLight4.Color = Color3.new(0.886275, 0.505882, 0.121569)
- PointLight4.Enabled = false
- PointLight4.Brightness = 4
- PointLight4.Range = 4
- PointLight4.Color = Color3.new(0.886275, 0.505882, 0.121569)
- PointLight5.Name = "RedLight"
- PointLight5.Parent = Part1
- PointLight5.Color = Color3.new(1, 0, 0)
- PointLight5.Enabled = false
- PointLight5.Brightness = 4
- PointLight5.Range = 4
- PointLight5.Color = Color3.new(1, 0, 0)
- SpotLight6.Parent = Part1
- SpotLight6.Color = Color3.new(1, 0, 0)
- SpotLight6.Enabled = false
- SpotLight6.Brightness = 8
- SpotLight6.Angle = 45
- SpotLight6.Color = Color3.new(1, 0, 0)
- Sound7.Name = "FireSound"
- Sound7.Parent = Part1
- Sound7.SoundId = "http://www.roblox.com/asset/?id=116745227"
- Part8.Name = "BarrelClip"
- Part8.Parent = Tool0
- Part8.Rotation = Vector3.new(88.9399948, -64.659996, 89.4300003)
- Part8.CanCollide = false
- Part8.FormFactor = Enum.FormFactor.Custom
- Part8.Size = Vector3.new(0.200000003, 0.200000003, 0.319990754)
- Part8.CFrame = CFrame.new(0.976270974, 32.3943062, -45.7094498, 0.00428991765, -0.427933723, -0.903802216, 0.0094730733, 0.903783858, -0.427882999, 0.999949038, -0.00672531035, 0.00793248415)
- Part8.Position = Vector3.new(0.976270974, 32.3943062, -45.7094498)
- Part8.Orientation = Vector3.new(25.3299999, -89.5, 0.599999964)
- SpecialMesh9.Parent = Part8
- SpecialMesh9.MeshId = "http://www.roblox.com/asset/?id=116740155"
- SpecialMesh9.Scale = Vector3.new(0.899999976, 0.899999976, 0.899999976)
- SpecialMesh9.TextureId = "http://www.roblox.com/asset/?id=116679995"
- SpecialMesh9.MeshType = Enum.MeshType.FileMesh
- SpecialMesh9.Scale = Vector3.new(0.899999976, 0.899999976, 0.899999976)
- Weld10.Parent = Part8
- Weld10.C0 = CFrame.new(0, 0, 0, 0.00777906645, 0.00690134289, 0.999947846, -0.0223223157, 0.99972713, -0.00672530197, -0.999722123, -0.0222686492, 0.00793247484)
- Weld10.C1 = CFrame.new(0.00955963135, -0.363422394, -0.235873222, 2.98023224e-08, 0, 1.0000006, 0, 1, 0, -1.0000006, 0, 2.98023224e-08)
- Weld10.Part0 = Part8
- Weld10.Part1 = Part1
- Script11.Parent = Part8
- table.insert(cors,sandbox(Script11,function()
- wait(.1)
- script.Parent:Destroy()
- wait(1)
- end))
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = game:GetService("Players").LocalPlayer.Backpack
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement