Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ROBLOX's rocket launcher tool remade and converted by Protofer_S, feel free to use it!
- local tool = Instance.new("Tool")
- tool.Archivable=true
- tool.CanBeDropped=false tool.RequiresHandle=true
- local handle = Instance.new("Part",tool) handle.Name='Handle'
- handle.Size=Vector3.new(4.92, 0.74, 0.84)
- tool.GripForward=Vector3.new(1,0,0)
- tool.GripPos=Vector3.new(0.7, 0, -0.5)
- tool.GripRight=Vector3.new(0, -1, 0)
- tool.GripUp=Vector3.new(0,0,1)
- print('Made by Protofer_S')
- local handle_mesh = Instance.new("SpecialMesh",handle) handle_mesh.MeshId='rbxasset://fonts/rocketlauncher.mesh'
- handle_mesh.TextureId='rbxasset://textures/rocketlaunchertex.png' handle_mesh.Scale=Vector3.new(0.75, 0.75, 0.75)
- tool.TextureId='http://www.roblox.com/asset/?id=90021376'
- tool.Parent=owner.Backpack
- function functions()
- NLS([[
- local Tool = script.Parent
- local Remote = Tool:WaitForChild("MouseLoc")
- local Mouse = game.Players.LocalPlayer:GetMouse()
- function Remote.OnClientInvoke()
- return Mouse.Hit.p
- end
- ]],handle.Parent)
- NLS([[
- 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)
- ]],handle.Parent)
- end
- functions()
- -----------------
- --| Constants |--
- -----------------
- local GRAVITY_ACCELERATION = workspace.Gravity
- local RELOAD_TIME = 1 -- Seconds until tool can be used again
- local ROCKET_SPEED = 100 -- Speed of the projectile
- local ROCKET_PART_SIZE = Vector3.new(1,1,4)
- --local MISSILE_MESH_ID = 'http://www.roblox.com/asset/?id=2251534'
- --local MISSILE_MESH_SCALE = Vector3.new(0.35, 0.35, 0.25)
- -----------------
- --| Variables |--
- -----------------
- local DebrisService = game:GetService('Debris')
- local PlayersService = game:GetService('Players')
- local MyPlayer
- local Tool = tool
- local ToolHandle = handle
- local MouseLoc = Instance.new("RemoteFunction",tool) MouseLoc.Name='MouseLoc'
- --local RocketScript = script:WaitForChild('Rocket')
- --local SwooshSound = Instance.new("Sound") SwooshSound.SoundId='rbxasset://sounds/Rocket whoosh 01.wav' SwooshSound.Looped=true
- --local BoomSound = Instance.new("Sound") BoomSound.PlayOnRemove=true BoomSound.Volume=0.7 BoomSound.SoundId='rbxasset://sounds/Rocket whoosh 01.wav'
- --NOTE: We create the rocket once and then clone it when the player fires
- local Rocket = Instance.new('FlagStand') do
- -- Set up the rocket 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
- -- Add the mesh
- --local mesh = Instance.new('SpecialMesh', Rocket)
- --mesh.MeshId = MISSILE_MESH_ID
- --mesh.Scale = MISSILE_MESH_SCALE
- -- Add fire
- --local fire = Instance.new('Fire', Rocket)
- --fire.Heat = 5
- --fire.Size = 2
- -- Add a force to counteract gravity
- local bodyForce = Instance.new('BodyForce', Rocket)
- bodyForce.Name = 'Antigravity'
- bodyForce.Force = Vector3.new(0, Rocket:GetMass() * GRAVITY_ACCELERATION, 0)
- -- Clone the sounds and set Boom to PlayOnRemove
- local swooshSoundClone = Instance.new("Sound") swooshSoundClone.SoundId='rbxasset://sounds/Rocket whoosh 01.wav' swooshSoundClone.Looped=true swooshSoundClone.Name='Swoosh' swooshSoundClone.Volume=0.7--SwooshSound:Clone()
- swooshSoundClone.Parent = Rocket swooshSoundClone:Play()
- local boomSoundClone = Instance.new("Sound") boomSoundClone.Volume=0.7 boomSoundClone.SoundId='rbxasset://sounds/collide.wav' boomSoundClone.Name='Boom' boomSoundClone.Volume=1 --BoomSound:Clone()
- boomSoundClone.PlayOnRemove = true
- boomSoundClone.Parent = Rocket
- -- Attach creator tags to the rocket early on
- local creatorTag = Instance.new('ObjectValue', Rocket)
- creatorTag.Value = MyPlayer
- creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
- local iconTag = Instance.new('StringValue', creatorTag)
- iconTag.Value = Tool.TextureId
- iconTag.Name = 'icon'
- function rocketfunctions(rocket)
- local BLAST_RADIUS = 10 -- Blast radius of the explosion
- local BLAST_FORCE = 600000 -- Amount of force applied to parts
- local swoosh=rocket:waitForChild('Swoosh')
- local function explode(victim)
- if victim:IsDescendantOf(MyPlayer.Character) then return end
- local beam= Instance.new("Explosion",workspace) beam.Position=rocket.Position
- beam.BlastRadius = BLAST_RADIUS
- beam.BlastPressure=BLAST_FORCE
- beam.ExplosionType = Enum.ExplosionType.Craters
- beam.Hit:Connect(function(part,distance)
- local hum = part.Parent:FindFirstChildOfClass('Humanoid')
- if hum then
- if hum.MaxHealth>110 then
- hum.Health=0 hum.MaxHealth=-20
- hum.Parent:BreakJoints()
- end
- local bad = hum.Parent:FindFirstChildOfClass('ForceField')
- if bad then
- bad:Destroy()
- hum.Parent:BreakJoints()
- wait(.2)
- hum:Destroy()
- end
- end
- end)
- swoosh:Pause()
- rocket:Destroy()
- end
- rocket.Touched:Connect(explode)
- end
- -- Finally, clone the rocket script and enable it
- --local rocketScriptClone = RocketScript:Clone()
- --rocketScriptClone.Parent = Rocket
- --rocketScriptClone.Disabled = false
- end
- -----------------
- --| Functions |--
- -----------------
- local function OnActivated()
- local myModel = MyPlayer.Character
- if Tool.Enabled and myModel and myModel:FindFirstChildOfClass("Humanoid") and myModel.Humanoid.Health > 0 then
- Tool.Enabled = false
- local Pos = MouseLoc:InvokeClient(MyPlayer)
- -- Create a clone of Rocket and set its color
- local rocketClone = Rocket:Clone()
- rocketfunctions(rocketClone)
- DebrisService:AddItem(rocketClone, 30)
- rocketClone.BrickColor = BrickColor.new("Bright blue")
- -- Position the rocket clone and launch!
- local spawnPosition = (ToolHandle.CFrame * CFrame.new(5, 0, 0)).p
- rocketClone.CFrame = CFrame.new(spawnPosition, Pos) --NOTE: This must be done before assigning Parent
- rocketClone.Velocity = rocketClone.CFrame.lookVector * ROCKET_SPEED --NOTE: This should be done before assigning Parent
- rocketClone.Parent = workspace
- rocketClone:SetNetworkOwner(nil)
- rocketClone.Material=Enum.Material.Plastic
- wait(RELOAD_TIME)
- Tool.Enabled = true
- end
- end
- function OnEquipped()
- MyPlayer = PlayersService:GetPlayerFromCharacter(Tool.Parent)
- end
- --------------------
- --| Script Logic |--
- --------------------
- tool.Equipped:Connect(OnEquipped)
- tool.Activated:Connect(OnActivated)
Advertisement
Advertisement