Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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")
- o4 = Instance.new("Decal")
- o5 = Instance.new("Decal")
- o6 = Instance.new("Sound")
- o7 = Instance.new("Sound")
- o8 = Instance.new("PointLight")
- o9 = Instance.new("LocalScript")
- o10 = Instance.new("LocalScript")
- o11 = Instance.new("Sound")
- o1.Name = "Arm Cannon"
- o1.Parent = mas
- o1.GripForward = Vector3.new(1, -0, -0)
- o1.GripRight = Vector3.new(0, 0, 1)
- o1.ToolTip = "Based off of Metroid"
- o2.Name = "Handle"
- o2.Parent = o1
- o2.Material = Enum.Material.SmoothPlastic
- o2.BrickColor = BrickColor.new("Shamrock")
- o2.Position = Vector3.new(1.5150001, 5.50499964, -0.914999843)
- o2.Rotation = Vector3.new(-0, -90, 0)
- o2.Size = Vector3.new(1.82999992, 1.13000011, 1.08999991)
- o2.CFrame = CFrame.new(1.5150001, 5.50499964, -0.914999843, 0, 0, -1.00000024, 0, 1, 0, 1.00000024, 0, 0)
- o2.BackSurface = Enum.SurfaceType.Weld
- o2.BottomSurface = Enum.SurfaceType.Weld
- o2.FrontSurface = Enum.SurfaceType.Weld
- o2.LeftSurface = Enum.SurfaceType.Weld
- o2.RightSurface = Enum.SurfaceType.Weld
- o2.TopSurface = Enum.SurfaceType.Weld
- o2.Color = Color3.new(0.356863, 0.603922, 0.298039)
- o2.Position = Vector3.new(1.5150001, 5.50499964, -0.914999843)
- o4.Parent = o2
- o4.Texture = "http://www.roblox.com/asset/?id=22285987"
- o4.Face = Enum.NormalId.Left
- o5.Parent = o2
- o5.Texture = "http://www.roblox.com/asset/?id=22285987"
- o5.Face = Enum.NormalId.Right
- o6.Name = "Fire"
- o6.Parent = o2
- o6.SoundId = "http://www.roblox.com/asset?id=130113322"
- o7.Name = "Reload"
- o7.Parent = o2
- o7.SoundId = "http://www.roblox.com/asset?id=130113370"
- o8.Parent = o2
- o8.Color = Color3.new(1, 1, 0)
- o8.Range = 6
- o9.Name = "MouseIcon"
- o9.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
- local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
- local Tool = script.Parent
- local Mouse = nil
- local function UpdateIcon()
- if Mouse then
- Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
- end
- end
- local function OnEquipped(mouse)
- Mouse = mouse
- UpdateIcon()
- end
- local function OnChanged(property)
- if property == 'Enabled' then
- UpdateIcon()
- end
- end
- Tool.Equipped:connect(OnEquipped)
- Tool.Changed:connect(OnChanged)
- end,o9)
- end))
- o10.Name = "ToolScript"
- o10.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- -----------------
- --| Constants |--
- -----------------
- local SHOT_SPEED = 100
- local SHOT_TIME = 1
- local NOZZLE_OFFSET = Vector3.new(0, 0.4, -1.1)
- -----------------
- --| Variables |--
- -----------------
- local PlayersService = Game:GetService('Players')
- local DebrisService = Game:GetService('Debris')
- local Tool = script.Parent
- local Handle = Tool:WaitForChild('Handle')
- local FireSound = Handle:WaitForChild('Fire')
- local ReloadSound = Handle:WaitForChild('Reload')
- local HitFadeSound = script:WaitForChild('HitFade')
- local PointLight = Handle:WaitForChild('PointLight')
- local Character = nil
- local Humanoid = nil
- local Player = nil
- local BaseShot = nil
- -----------------
- --| Functions |--
- -----------------
- -- Returns a character ancestor and its Humanoid, or nil
- local function FindCharacterAncestor(subject)
- if subject and subject ~= Workspace then
- local humanoid = subject:FindFirstChild('Humanoid')
- if humanoid then
- return subject, humanoid
- else
- return FindCharacterAncestor(subject.Parent)
- end
- end
- return nil
- end
- -- Removes any old creator tags and applies new ones to the specified target
- local function ApplyTags(target)
- while target:FindFirstChild('creator') do
- target.creator:Destroy()
- end
- local creatorTag = Instance.new('ObjectValue')
- creatorTag.Value = Player
- creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
- local iconTag = Instance.new('StringValue')
- iconTag.Value = Tool.TextureId
- iconTag.Name = 'icon'
- iconTag.Parent = creatorTag
- creatorTag.Parent = target
- DebrisService:AddItem(creatorTag, 4)
- end
- -- Returns all objects under instance with Transparency
- local function GetTransparentsRecursive(instance, partsTable)
- local partsTable = partsTable or {}
- for _, child in pairs(instance:GetChildren()) do
- if child:IsA('BasePart') or child:IsA('Decal') then
- table.insert(partsTable, child)
- end
- GetTransparentsRecursive(child, partsTable)
- end
- return partsTable
- end
- local function SelectionBoxify(instance)
- local selectionBox = Instance.new('SelectionBox')
- selectionBox.Adornee = instance
- selectionBox.Color = BrickColor.new('New Yeller')
- selectionBox.Parent = instance
- return selectionBox
- end
- local function Light(instance)
- local light = PointLight:Clone()
- light.Range = light.Range + 2
- light.Parent = instance
- end
- local function FadeOutObjects(objectsWithTransparency, fadeIncrement)
- repeat
- local lastObject = nil
- for _, object in pairs(objectsWithTransparency) do
- object.Transparency = object.Transparency + fadeIncrement
- lastObject = object
- end
- wait()
- until lastObject.Transparency >= 1 or not lastObject
- end
- local function Dematerialize(character, humanoid, firstPart)
- humanoid.WalkSpeed = 0
- local parts = {}
- for _, child in pairs(character:GetChildren()) do
- if child:IsA('BasePart') then
- child.Anchored = true
- table.insert(parts, child)
- elseif child:IsA('LocalScript') or child:IsA('Script') then
- child:Destroy()
- end
- end
- local selectionBoxes = {}
- local firstSelectionBox = SelectionBoxify(firstPart)
- Light(firstPart)
- wait(0.05)
- for _, part in pairs(parts) do
- if part ~= firstPart then
- table.insert(selectionBoxes, SelectionBoxify(part))
- Light(part)
- end
- end
- local objectsWithTransparency = GetTransparentsRecursive(character)
- FadeOutObjects(objectsWithTransparency, 0.1)
- wait(0.5)
- humanoid.Health = 0
- DebrisService:AddItem(character, 2)
- local fadeIncrement = 0.05
- Delay(0.2, function()
- FadeOutObjects({firstSelectionBox}, fadeIncrement)
- if character then
- character:Destroy()
- end
- end)
- FadeOutObjects(selectionBoxes, fadeIncrement)
- end
- local function OnTouched(shot, otherPart)
- local character, humanoid = FindCharacterAncestor(otherPart)
- if character and humanoid and character ~= Character then
- ApplyTags(humanoid)
- if shot then
- local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
- if hitFadeSound then
- hitFadeSound.Parent = humanoid.Torso
- hitFadeSound:Play()
- end
- shot:Destroy()
- end
- Dematerialize(character, humanoid, otherPart)
- end
- end
- local function OnEquipped()
- Character = Tool.Parent
- Humanoid = Character:WaitForChild('Humanoid')
- Player = PlayersService:GetPlayerFromCharacter(Character)
- end
- local function OnActivated()
- if Tool.Enabled and Humanoid.Health > 0 then
- Tool.Enabled = false
- FireSound:Play()
- local handleCFrame = Handle.CFrame
- local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
- local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)
- local laserShotClone = BaseShot:Clone()
- laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
- local bodyVelocity = Instance.new('BodyVelocity')
- bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
- bodyVelocity.Parent = laserShotClone
- laserShotClone.Touched:connect(function(otherPart)
- OnTouched(laserShotClone, otherPart)
- end)
- DebrisService:AddItem(laserShotClone, SHOT_TIME)
- laserShotClone.Parent = Tool
- wait(0.6) -- FireSound length
- ReloadSound:Play()
- wait(0.75) -- ReloadSound length
- Tool.Enabled = true
- end
- end
- local function OnUnequipped()
- end
- --------------------
- --| Script Logic |--
- --------------------
- BaseShot = Instance.new('Part')
- BaseShot.Name = 'Effect'
- BaseShot.FormFactor = Enum.FormFactor.Custom
- BaseShot.Size = Vector3.new(0.2, 0.2, 3)
- BaseShot.CanCollide = false
- BaseShot.BrickColor = BrickColor.new('Toothpaste')
- SelectionBoxify(BaseShot)
- Light(BaseShot)
- HitFadeSound:Clone().Parent = BaseShot
- Tool.Equipped:connect(OnEquipped)
- Tool.Unequipped:connect(OnUnequipped)
- Tool.Activated:connect(OnActivated)
- end,o10)
- end))
- o11.Name = "HitFade"
- o11.Parent = o10
- o11.SoundId = "http://www.roblox.com/asset?id=130113415"
- 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