Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --:3
- 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")
- Sound2 = Instance.new("Sound")
- SpecialMesh3 = Instance.new("SpecialMesh")
- LocalScript4 = Instance.new("LocalScript")
- Script5 = Instance.new("Script")
- Sound6 = Instance.new("Sound")
- Sound7 = Instance.new("Sound")
- Script8 = Instance.new("Script")
- LocalScript9 = Instance.new("LocalScript")
- Animation10 = Instance.new("Animation")
- LocalScript11 = Instance.new("LocalScript")
- LocalScript12 = Instance.new("LocalScript")
- ObjectValue13 = Instance.new("ObjectValue")
- Tool0.Name = "Super OP LoTMLauncher"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset/?id=135409747"
- Tool0.GripPos = Vector3.new(0.0500000007, -0.600000024, -1)
- Tool0.ToolTip = "EXTREMELY OP USE OF CAUTION"
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.FormFactor = Enum.FormFactor.Custom
- Part1.Size = Vector3.new(0.839999974, 1.14999998, 3.55000019)
- Part1.CFrame = CFrame.new(1, 0.574999988, 12.4000015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.Position = Vector3.new(1, 0.574999988, 12.4000015)
- Sound2.Name = "ReloadSound"
- Sound2.Parent = Part1
- Sound2.SoundId = "http://www.roblox.com/Asset?ID=10209813"
- Sound2.Volume = 1
- SpecialMesh3.Parent = Part1
- SpecialMesh3.MeshId = "http://www.roblox.com/asset/?id=125754898"
- SpecialMesh3.TextureId = "http://www.roblox.com/asset/?id=125755118"
- SpecialMesh3.VertexColor = Vector3.new(1, 0, 0)
- SpecialMesh3.MeshType = Enum.MeshType.FileMesh
- LocalScript4.Name = "MouseIcon"
- LocalScript4.Parent = Tool0
- table.insert(cors,sandbox(LocalScript4,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()
- Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
- 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))
- Script5.Name = "Launcher"
- Script5.Parent = Tool0
- table.insert(cors,sandbox(Script5,function()
- -----------------
- --| Constants |--
- -----------------
- local COOLDOWN = 0 -- Seconds until tool can be used again
- -- RocketPropulsion Fields
- local TARGET_RADIUS = 70
- local MAX_SPEED = 2500
- local MAX_TORQUE = Vector3.new(4e6, 4e6, 0)
- local MAX_THRUST = 640000
- local THRUST_P = 6700
- local THRUST_D = 67000
- local TARGET_OVERSHOOT_DISTANCE = 10000000
- local ROCKET_MESH_ID = 'http://www.roblox.com/asset/?id=16974203'
- local ROCKET_MESH_SCALE = Vector3.new(2.5, 2.5, 2)
- local ROCKET_PART_SIZE = Vector3.new(1, 1, 4)
- --------------------
- --| WaitForChild |--
- --------------------
- -- Waits for parent.child to exist, then returns it
- local function WaitForChild(parent, childName)
- assert(parent, "ERROR: WaitForChild: parent is nil")
- while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
- return parent[childName]
- end
- -----------------
- --| Variables |--
- -----------------
- local DebrisService = Game:GetService('Debris')
- local PlayersService = Game:GetService('Players')
- local Tool = script.Parent
- local ToolHandle = Tool.Handle
- local RocketScript = WaitForChild(script, 'Rocket')
- local SwooshSound = WaitForChild(script, 'Swoosh')
- local BoomSound = WaitForChild(script, 'Boom')
- local ReloadSound = WaitForChild(ToolHandle, 'ReloadSound')
- local MyModel = nil
- local MyPlayer = nil
- local BaseRocket = nil
- local RocketClone = nil
- -----------------
- --| Functions |--
- -----------------
- local function MakeBaseRocket()
- -- Set up the rocket part
- local rocket = Instance.new('Part')
- rocket.Name = 'Rocket'
- rocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
- rocket.Size = ROCKET_PART_SIZE
- rocket.CanCollide = false
- rocket.BottomSurface = Enum.SurfaceType.Smooth
- rocket.TopSurface = Enum.SurfaceType.Smooth
- -- Add the mesh
- local mesh = Instance.new('SpecialMesh', rocket)
- mesh.MeshId = ROCKET_MESH_ID
- mesh.Scale = ROCKET_MESH_SCALE
- mesh.TextureId = ToolHandle.Mesh.TextureId
- -- Add fire
- local fire = Instance.new('Fire', rocket)
- fire.Heat = 10
- fire.Size = 10
- -- Add the propulsion
- local rocketPropulsion = Instance.new('RocketPropulsion', rocket)
- rocketPropulsion.CartoonFactor = 1
- rocketPropulsion.TargetRadius = TARGET_RADIUS
- rocketPropulsion.MaxSpeed = MAX_SPEED
- rocketPropulsion.MaxTorque = MAX_TORQUE
- rocketPropulsion.MaxThrust = MAX_THRUST
- rocketPropulsion.ThrustP = THRUST_P
- rocketPropulsion.ThrustD = THRUST_D
- -- Clone the sounds
- local swooshSoundClone = SwooshSound:Clone()
- swooshSoundClone.Parent = rocket
- local boomSoundClone = BoomSound:Clone()
- boomSoundClone.Parent = rocket
- -- Attach creator tags
- local creatorTag = Instance.new('ObjectValue', rocket)
- creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
- creatorTag.Value = MyPlayer
- local iconTag = Instance.new('StringValue', creatorTag)
- iconTag.Name = 'icon'
- iconTag.Value = Tool.TextureId
- -- Finally, clone the rocket script and enable it
- local rocketScriptClone = RocketScript:Clone()
- rocketScriptClone.Parent = rocket
- rocketScriptClone.Disabled = false
- return rocket
- end
- local function OnEquipped()
- MyModel = Tool.Parent
- MyPlayer = PlayersService:GetPlayerFromCharacter(MyModel)
- BaseRocket = MakeBaseRocket()
- RocketClone = BaseRocket:Clone()
- end
- local function OnActivated(byFireButton)
- if Tool.Enabled and MyModel and MyModel:FindFirstChild('Humanoid') and MyModel.Humanoid.Health > 0 then
- Tool.Enabled = false
- -- Get the target position
- local targetPosition = MyModel.Humanoid.TargetPoint
- if byFireButton then -- Using Fire Button, shoot forwards
- targetPosition = MyModel.Humanoid.Torso.CFrame.lookVector * 1000
- end
- -- Position the rocket clone
- local spawnPosition = ToolHandle.Position + (ToolHandle.CFrame.lookVector * (ToolHandle.Size.z / 2))
- RocketClone.CFrame = CFrame.new(spawnPosition, targetPosition) --NOTE: This must be done before assigning Parent
- DebrisService:AddItem(RocketClone, 30)
- RocketClone.Parent = Workspace
- -- Assign target and launch!
- local rocketPropulsion = RocketClone:FindFirstChild('RocketPropulsion')
- if rocketPropulsion then
- local direction = (targetPosition - RocketClone.Position).unit
- rocketPropulsion.TargetOffset = RocketClone.Position + (direction * TARGET_OVERSHOOT_DISTANCE)
- rocketPropulsion:Fire()
- end
- wait(0) --TODO: Remove when sounds realize they can be played as soon as they enter the Workspace
- -- Swoosh!
- local swooshSound = RocketClone:FindFirstChild('Swoosh')
- if swooshSound then
- swooshSound:Play()
- end
- -- Prepare the next rocket to be fired
- RocketClone = BaseRocket:Clone()
- ReloadSound:Play()
- wait(COOLDOWN)
- -- Stop the reloading sound if it hasn't already finished
- ReloadSound:Stop()
- Tool.Enabled = true
- end
- end
- local function OnUnequipped()
- ReloadSound:Stop() --TODO: This does not work online
- end
- -- Also activate when the Fire Button is down
- local function OnChildAdded(child)
- if child.Name == 'FireButtonDown' then
- child.Changed:connect(function(newValue)
- if newValue == true then
- OnActivated(true)
- end
- end)
- end
- end
- --------------------
- --| Script Logic |--
- --------------------
- Tool.Equipped:connect(OnEquipped)
- Tool.Activated:connect(OnActivated)
- Tool.Unequipped:connect(OnUnequipped)
- Tool.ChildAdded:connect(OnChildAdded) --NOTE: Added for Fire Button
- end))
- Sound6.Name = "Boom"
- Sound6.Parent = Script5
- Sound6.SoundId = "http://www.roblox.com/asset/?id=78491401"
- Sound6.Volume = 1
- Sound7.Name = "Swoosh"
- Sound7.Parent = Script5
- Sound7.SoundId = "http://www.roblox.com/asset/?id=10209821"
- Sound7.Volume = 0.69999998807907
- Sound7.Looped = true
- Script8.Name = "Rocket"
- Script8.Parent = Script5
- Script8.Disabled = true
- table.insert(cors,sandbox(Script8,function()
- -----------------
- --| Constants |--
- -----------------
- local BLAST_RADIUS = 130
- local BLAST_PRESSURE = 1000000
- -- Rocket will fly through things named these
- local ROCKET_IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} --NOTE: Keys must be lowercase, values must evaluate to true
- --------------------
- --| WaitForChild |--
- --------------------
- -- Waits for parent.child to exist, then returns it
- local function WaitForChild(parent, childName)
- assert(parent, "ERROR: WaitForChild: parent is nil")
- while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
- return parent[childName]
- end
- -----------------
- --| Variables |--
- -----------------
- local DebrisService = Game:GetService('Debris')
- local Rocket = script.Parent
- local CreatorTag = WaitForChild(Rocket, 'creator')
- local Connection = nil
- -----------------
- --| Functions |--
- -----------------
- -- Returns the ancestor that contains a Humanoid, if it exists
- 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
- local function OnExplosionHit(hitPart)
- if hitPart then
- local _, humanoid = FindCharacterAncestor(hitPart.Parent)
- if humanoid and humanoid.Health > 0 then
- local hitBindable = humanoid:FindFirstChild('Hit')
- if hitBindable then
- hitBindable:Invoke(0, CreatorTag)
- else
- print("Could not find BindableFunction 'Hit'")
- end
- end
- end
- end
- local function OnTouched(otherPart)
- if Rocket and otherPart then
- -- Fly through anything in the ignore list
- if ROCKET_IGNORE_LIST[string.lower(otherPart.Name)] then
- return
- end
- -- Fly through the creator
- local myPlayer = CreatorTag.Value
- if myPlayer and myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
- return
- end
- -- Create the explosion
- local explosion = Instance.new('Explosion')
- explosion.BlastPressure = BLAST_PRESSURE
- explosion.BlastRadius = BLAST_RADIUS
- explosion.Position = Rocket.Position
- explosion.Hit:connect(OnExplosionHit)
- explosion.Parent = Workspace
- -- Start playing the boom sound
- local boomSound = Rocket:FindFirstChild('Boom')
- if boomSound then
- boomSound:Play()
- end
- -- NOTE:
- -- If we just destroyed the rocket at this point, the boom sound would be destroyed too,
- -- so instead we will hide the rocket, keep it in the same spot, and schedule it for deletion
- -- Stop playing the swoosh sound
- local swooshSound = Rocket:FindFirstChild('Swoosh')
- if swooshSound then
- swooshSound:Stop()
- end
- -- Put out the fire
- local fire = Rocket:FindFirstChild('Fire')
- if fire then
- fire:Destroy()
- end
- Rocket.Transparency = 1
- Rocket.CanCollide = false
- Rocket.Anchored = true
- DebrisService:AddItem(Rocket, 3)
- -- Destroy the connection so this method won't be called again
- Connection:disconnect()
- end
- end
- --------------------
- --| Script Logic |--
- --------------------
- -- Arm the rocket and save the touch connection so we can disconnect it later
- Connection = Rocket.Touched:connect(OnTouched)
- end))
- LocalScript9.Name = "Animation"
- LocalScript9.Parent = Tool0
- table.insert(cors,sandbox(LocalScript9,function()
- --------------------
- --| WaitForChild |--
- --------------------
- -- Waits for parent.child to exist, then returns it
- local function WaitForChild(parent, childName)
- assert(parent, "ERROR: WaitForChild: parent is nil")
- while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
- return parent[childName]
- end
- -----------------
- --| Variables |--
- -----------------
- local Tool = script.Parent
- local FireAndReloadAnimation = WaitForChild(script, 'FireAndReload')
- local FireAndReloadTrack = nil
- -----------------
- --| Functions |--
- -----------------
- local function OnEquipped()
- local myModel = Tool.Parent
- local humanoid = myModel:FindFirstChild('Humanoid')
- if humanoid then -- Preload animations
- FireAndReloadTrack = humanoid:LoadAnimation(FireAndReloadAnimation)
- end
- end
- local function OnChanged(property)
- if property == 'Enabled' and Tool.Enabled == false then
- -- Play fire and reload animation
- if FireAndReloadTrack then
- FireAndReloadTrack:Play()
- end
- end
- end
- local function OnUnequipped()
- -- Stop animations
- if FireAndReloadTrack then FireAndReloadTrack:Stop() end
- end
- --------------------
- --| Script Logic |--
- --------------------
- Tool.Equipped:connect(OnEquipped)
- Tool.Changed:connect(OnChanged)
- Tool.Unequipped:connect(OnUnequipped)
- end))
- Animation10.Name = "FireAndReload"
- Animation10.Parent = LocalScript9
- Animation10.AnimationId = "http://www.roblox.com/Asset?ID=94771598"
- LocalScript11.Name = "VisualizeReload"
- LocalScript11.Parent = Tool0
- table.insert(cors,sandbox(LocalScript11,function()
- -----------------
- --| Constants |--
- -----------------
- local ROCKET_MESH_ID = 'http://www.roblox.com/asset/?id=16974203'
- local ROCKET_MESH_SCALE = Vector3.new(1, 1, 1)
- local ANIM_TOTAL_TIME = 3.4 -- Total length of FireAndReload animation
- local ROCKET_SHOW_TIME = 1.5 -- Seconds after animation begins to show the rocket
- local ROCKET_HIDE_TIME = 2.2 -- Seconds after animation begins to hide the rocket
- -----------------
- --| Variables |--
- -----------------
- local Tool = script.Parent
- local ToolHandle = Tool.Handle
- local MyModel = nil
- local ReloadRocket = nil
- local StillEquipped = false
- -----------------
- --| Functions |--
- -----------------
- local function MakeReloadRocket()
- local reloadRocket = Instance.new('Part')
- reloadRocket.Name = "Ammo"
- reloadRocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
- reloadRocket.Size = Vector3.new() -- As small as possible
- local mesh = Instance.new('SpecialMesh', reloadRocket)
- mesh.MeshId = ROCKET_MESH_ID
- mesh.Scale = ROCKET_MESH_SCALE
- mesh.TextureId = ToolHandle.Mesh.TextureId
- return reloadRocket
- end
- local function OnEquipped()
- MyModel = Tool.Parent
- ReloadRocket = MakeReloadRocket()
- end
- local function OnChanged(property)
- if property == 'Enabled' and Tool.Enabled == false then
- -- Show the next rocket going into the launcher
- StillEquipped = true
- wait(ROCKET_SHOW_TIME)
- if StillEquipped then
- local leftArm = MyModel:FindFirstChild('Left Arm')
- if leftArm then
- local weld = ReloadRocket:FindFirstChild('Weld')
- if not weld then
- weld = Instance.new('Weld')
- weld.Part0 = leftArm
- weld.Part1 = ReloadRocket
- weld.C1 = CFrame.new(Vector3.new(0, 1, 0))
- weld.Parent = ReloadRocket
- end
- ReloadRocket.Parent = MyModel
- end
- wait(ROCKET_HIDE_TIME - ROCKET_SHOW_TIME)
- if StillEquipped and ReloadRocket.Parent == MyModel then
- ReloadRocket.Parent = nil
- end
- end
- end
- end
- local function OnUnequipped()
- StillEquipped = false
- ReloadRocket:Destroy()
- ReloadRocket = nil
- end
- --------------------
- --| Script Logic |--
- --------------------
- Tool.Equipped:connect(OnEquipped)
- Tool.Changed:connect(OnChanged)
- Tool.Unequipped:connect(OnUnequipped)
- end))
- LocalScript12.Name = "EpicEffect"
- LocalScript12.Parent = Tool0
- table.insert(cors,sandbox(LocalScript12,function()
- Tool = script.Parent
- gyro = Instance.new("BodyGyro")
- script.Gyro.Value = gyro
- onMouseMove=function(mouse)
- vCharacter = Tool.Parent
- if vCharacter ~= nil then
- local tp = vCharacter.Humanoid.TargetPoint
- tp = Vector3.new(tp.X,Tool.Parent.Torso.Position.Y,tp.Z)
- local dir = (tp - Tool.Parent.Torso.Position).unit
- local spawnPos = Tool.Parent.Torso.Position
- local pos = spawnPos + (dir * 1)
- script.Gyro.Value.cframe = CFrame.new(pos, pos + dir)
- end
- end
- onEquipped=function(mouse)
- for i,k in pairs(Tool.Parent.Torso:GetChildren()) do
- if k:IsA("BodyGyro") then
- k.Parent=nil
- end
- end
- wait(0.1)
- script.Gyro.Value.Parent = Tool.Parent:findFirstChild("Torso")
- script.Gyro.Value.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
- mouse.Move:connect(function() onMouseMove(mouse) end)
- end
- onUnequipped=function()
- script.Gyro.Value.Parent = nil
- wait(0.01)
- for i,k in pairs(Tool.Parent.Torso:GetChildren()) do
- if k:IsA("BodyGyro") then
- k.Parent=nil
- end
- end
- end
- Tool.Equipped:connect(onEquipped)
- Tool.Unequipped:connect(onUnequipped)
- end))
- ObjectValue13.Name = "Gyro"
- ObjectValue13.Parent = LocalScript12
- 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
Add Comment
Please, Sign In to add comment