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")
- SpecialMesh2 = Instance.new("SpecialMesh")
- Script3 = Instance.new("Script")
- Sound4 = Instance.new("Sound")
- Sound5 = Instance.new("Sound")
- Script6 = Instance.new("Script")
- LocalScript7 = Instance.new("LocalScript")
- Configuration8 = Instance.new("Configuration")
- NumberValue9 = Instance.new("NumberValue")
- IntValue10 = Instance.new("IntValue")
- NumberValue11 = Instance.new("NumberValue")
- IntValue12 = Instance.new("IntValue")
- IntValue13 = Instance.new("IntValue")
- IntValue14 = Instance.new("IntValue")
- Tool0.Name = "RocketLauncher"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset/?id=90021376"
- Tool0.GripForward = Vector3.new(1, -0, -0)
- Tool0.GripPos = Vector3.new(0.699999988, 0, -0.5)
- Tool0.GripRight = Vector3.new(0, -1, 0)
- Tool0.GripUp = Vector3.new(0, 0, 1)
- Tool0.CanBeDropped = false
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.Rotation = Vector3.new(-114.07, -14.1599998, 10.2299995)
- Part1.CanCollide = false
- Part1.FormFactor = Enum.FormFactor.Custom
- Part1.Size = Vector3.new(4.92000628, 0.740000546, 0.839999795)
- Part1.CFrame = CFrame.new(2.58627033, 1.04310119, 1.80223536, 0.954189599, -0.172256514, -0.244642451, 0.147373959, -0.441000789, 0.885324597, -0.260390431, -0.880821466, -0.395412236)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.Position = Vector3.new(2.58627033, 1.04310119, 1.80223536)
- Part1.Orientation = Vector3.new(-62.2899971, -148.25, 161.519989)
- SpecialMesh2.Parent = Part1
- SpecialMesh2.MeshId = "rbxasset://fonts/rocketlauncher.mesh"
- SpecialMesh2.Scale = Vector3.new(0.75, 0.75, 0.75)
- SpecialMesh2.TextureId = "rbxasset://textures/rocketlaunchertex.png"
- SpecialMesh2.MeshType = Enum.MeshType.FileMesh
- SpecialMesh2.Scale = Vector3.new(0.75, 0.75, 0.75)
- Script3.Parent = Tool0
- table.insert(cors,sandbox(Script3,function()
- local tool = script.Parent
- local canFire = true
- local gunWeld
- -----------------
- --| Constants |--
- -----------------
- local GRAVITY_ACCELERATION = 196.2
- local RELOAD_TIME = tool.Configurations.ReloadTime.Value -- Seconds until tool can be used again
- local ROCKET_SPEED = tool.Configurations.RocketSpeed.Value -- Speed of the projectile
- local MISSILE_MESH_ID = 'http://www.roblox.com/asset/?id=2251534'
- local MISSILE_MESH_SCALE = Vector3.new(0.35, 0.35, 0.25)
- local ROCKET_PART_SIZE = Vector3.new(1.2, 1.2, 3.27)
- local RocketScript = script:WaitForChild('Rocket')
- local SwooshSound = script:WaitForChild('Swoosh')
- local BoomSound = script:WaitForChild('Boom')
- local attackCooldown = tool.Configurations.AttackCooldown.Value
- local damage = tool.Configurations.Damage.Value
- local reloadTime = tool.Configurations.ReloadTime.Value
- local function createEvent(eventName)
- local event = game.ReplicatedStorage:FindFirstChild(eventName)
- if not event then
- event = Instance.new("RemoteEvent", game.ReplicatedStorage)
- event.Name = eventName
- end
- return event
- end
- local updateEvent = createEvent("ROBLOX_RocketUpdateEvent")
- local equipEvent = createEvent("ROBLOX_RocketEquipEvent")
- local unequipEvent = createEvent("ROBLOX_RocketUnequipEvent")
- local fireEvent = createEvent("ROBLOX_RocketFireEvent")
- updateEvent.OnServerEvent:connect(function(player, neckC0, rshoulderC0)
- local character = player.Character
- character.Torso.Neck.C0 = neckC0
- character.Torso:FindFirstChild("Right Shoulder").C0 = rshoulderC0
- gunWeld = character:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
- end)
- equipEvent.OnServerEvent:connect(function(player)
- player.Character.Humanoid.AutoRotate = false
- end)
- unequipEvent.OnServerEvent:connect(function(player)
- player.Character.Humanoid.AutoRotate = true
- end)
- --NOTE: We create the rocket once and then clone it when the player fires
- local Rocket = Instance.new('Part') 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 = SwooshSound:Clone()
- swooshSoundClone.Parent = Rocket
- local boomSoundClone = BoomSound:Clone()
- boomSoundClone.PlayOnRemove = true
- boomSoundClone.Parent = Rocket
- -- Finally, clone the rocket script and enable it
- -- local rocketScriptClone = RocketScript:Clone()
- -- rocketScriptClone.Parent = Rocket
- -- rocketScriptClone.Disabled = false
- end
- fireEvent.OnServerEvent:connect(function(player, target)
- if canFire and player.Character == tool.Parent then
- canFire = false
- -- Create a clone of Rocket and set its color
- local rocketClone = Rocket:Clone()
- --game.Debris:AddItem(rocketClone, 30)
- rocketClone.BrickColor = player.TeamColor
- rocketClone.Touched:connect(function(hit)
- if hit and hit.Parent and hit.Parent ~= player.Character and hit.Parent ~= tool then
- local explosion = Instance.new("Explosion", game.Workspace)
- explosion.BlastRadius = 100
- explosion.BlastPressure = 1000000
- explosion.Position = rocketClone.Position
- explosion.Hit:connect(function(Part, Distance)
- Part.Anchored = false
- if Distance <= 200 then
- Part:BreakJoints()
- end
- end)
- rocketClone:Destroy()
- end
- end)
- spawn(function()
- wait(30)
- if rocketClone then rocketClone:Destroy() end
- end)
- -- Position the rocket clone and launch!
- local spawnPosition = (tool.Handle.CFrame * CFrame.new(2, 0, 0)).p
- rocketClone.CFrame = CFrame.new(spawnPosition, target) --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 = game.Workspace
- -- Attach creator tags to the rocket early on
- local creatorTag = Instance.new('ObjectValue', rocketClone)
- creatorTag.Value = player
- creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
- local iconTag = Instance.new('StringValue', creatorTag)
- iconTag.Value = tool.TextureId
- iconTag.Name = 'icon'
- delay(attackCooldown, function()
- canFire = true
- end)
- end
- end)
- end))
- Sound4.Name = "Boom"
- Sound4.Parent = Script3
- Sound4.SoundId = "rbxassetid://919941001"
- Sound4.Volume = 1
- Sound5.Name = "Swoosh"
- Sound5.Parent = Script3
- Sound5.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
- Sound5.Volume = 0.69999998807907
- Sound5.Looped = true
- Script6.Name = "Rocket"
- Script6.Parent = Script3
- table.insert(cors,sandbox(Script6,function()
- -----------------
- --| Constants |--
- -----------------
- local BLAST_RADIUS = script.Parent.Parent.Configurations.BlastRadius.Value -- Blast radius of the explosion
- local BLAST_DAMAGE = script.Parent.Parent.Configurations.Damage.Value -- Amount of damage done to players
- local BLAST_FORCE = script.Parent.Parent.Configurations.BlastForce.Value -- Amount of force applied to parts
- local IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} -- Rocket will fly through things named these
- --NOTE: Keys must be lowercase, values must evaluate to true
- -----------------
- --| Variables |--
- -----------------
- local DebrisService = game:GetService('Debris')
- local PlayersService = game:GetService('Players')
- local Rocket = script.Parent
- local CreatorTag = Rocket:WaitForChild('creator')
- local SwooshSound = Rocket:WaitForChild('Swoosh')
- -----------------
- --| Functions |--
- -----------------
- -- Removes any old creator tags and applies a new one to the target
- local function ApplyTags(target)
- while target:FindFirstChild('creator') do
- target.creator:Destroy()
- end
- local creatorTagClone = CreatorTag:Clone()
- DebrisService:AddItem(creatorTagClone, 1.5)
- creatorTagClone.Parent = target
- end
- -- Returns the ancestor that contains a Humanoid, if it exists
- local function FindCharacterAncestor(subject)
- if subject and subject ~= game.Workspace then
- local humanoid = subject:FindFirstChild('Humanoid')
- if humanoid then
- return subject, humanoid
- else
- return FindCharacterAncestor(subject.Parent)
- end
- end
- return nil
- end
- -- Customized explosive effect that doesn't affect teammates and only breaks joints on dead parts
- local function OnExplosionHit(hitPart, hitDistance, blastCenter)
- if hitPart and hitDistance then
- local character, humanoid = FindCharacterAncestor(hitPart.Parent)
- if character then
- local myPlayer = CreatorTag.Value
- if myPlayer and not myPlayer.Neutral then -- Ignore friendlies caught in the blast
- local player = PlayersService:GetPlayerFromCharacter(character)
- if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
- return
- end
- end
- end
- if humanoid and humanoid.Health > 0 then -- Humanoids are tagged and damaged
- if hitPart.Name == 'Torso' then
- ApplyTags(humanoid)
- humanoid:TakeDamage(BLAST_DAMAGE)
- end
- else -- Loose parts and dead parts are blasted
- if hitPart.Name ~= 'Handle' then
- hitPart:BreakJoints()
- local blastForce = Instance.new('BodyForce', hitPart) --NOTE: We will multiply by mass so bigger parts get blasted more
- blastForce.force = (hitPart.Position - blastCenter).unit * BLAST_FORCE * hitPart:GetMass()
- DebrisService:AddItem(blastForce, 0.1)
- end
- end
- end
- end
- local function OnTouched(otherPart)
- if Rocket and otherPart then
- -- Fly through anything in the ignore list
- if IGNORE_LIST[string.lower(otherPart.Name)] then
- return
- end
- local myPlayer = CreatorTag.Value
- if myPlayer then
- -- Fly through the creator
- if myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
- return
- end
- -- Fly through friendlies
- if not myPlayer.Neutral then
- local character = FindCharacterAncestor(otherPart.Parent)
- local player = PlayersService:GetPlayerFromCharacter(character)
- if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
- return
- end
- end
- end
- -- Fly through terrain water
- if otherPart == game.Workspace.Terrain then
- --NOTE: If the rocket is large, then the simplifications made here will cause it to fly through terrain in some cases
- local frontOfRocket = Rocket.Position + (Rocket.CFrame.lookVector * (Rocket.Size.Z / 2))
- local cellLocation = game.Workspace.Terrain:WorldToCellPreferSolid(frontOfRocket)
- local cellMaterial = game.Workspace.Terrain:GetCell(cellLocation.X, cellLocation.Y, cellLocation.Z)
- if cellMaterial == Enum.CellMaterial.Water or cellMaterial == Enum.CellMaterial.Empty then
- return
- end
- end
- -- Create the explosion
- local explosion = Instance.new('Explosion')
- explosion.BlastPressure = 0 -- Completely safe explosion
- explosion.BlastRadius = BLAST_RADIUS
- explosion.ExplosionType = Enum.ExplosionType.NoCraters
- explosion.Position = Rocket.Position
- explosion.Parent = game.Workspace
- -- Connect custom logic for the explosion
- explosion.Hit:connect(function(hitPart, hitDistance) OnExplosionHit(hitPart, hitDistance, explosion.Position) end)
- -- Move this script and the creator tag (so our custom logic can execute), then destroy the rocket
- script.Parent = explosion
- CreatorTag.Parent = script
- Rocket:Destroy()
- end
- end
- --------------------
- --| Script Logic |--
- --------------------
- SwooshSound:Play()
- Rocket.Touched:connect(OnTouched)
- end))
- LocalScript7.Parent = Tool0
- table.insert(cors,sandbox(LocalScript7,function()
- -- Variables for services
- local render = game:GetService("RunService").RenderStepped
- local contextActionService = game:GetService("ContextActionService")
- local userInputService = game:GetService("UserInputService")
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local Tool = script.Parent
- -- Variables for Module Scripts
- local screenSpace = require(Tool:WaitForChild("ScreenSpace"))
- local connection
- local neck, shoulder, oldNeckC0, oldShoulderC0
- local mobileShouldTrack = true
- -- Thourough check to see if a character is sitting
- local function amISitting(character)
- local t = character.Torso
- for _, part in pairs(t:GetConnectedParts(true)) do
- if part:IsA("Seat") or part:IsA("VehicleSeat") then
- return true
- end
- end
- end
- -- Function to call on renderstepped. Orients the character so it is facing towards
- -- the player mouse's position in world space. If character is sitting then the torso
- -- should not track
- local function frame(mousePosition)
- -- Special mobile consideration. We don't want to track if the user was touching a ui
- -- element such as the movement controls. Just return out of function if so to make sure
- -- character doesn't track
- if not mobileShouldTrack then return end
- -- Make sure character isn't swiming. If the character is swimming the following code will
- -- not work well; the character will not swim correctly. Besides, who shoots underwater?
- if player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming then
- local torso = player.Character.Torso
- local head = player.Character.Head
- local toMouse = (mousePosition - head.Position).unit
- local angle = math.acos(toMouse:Dot(Vector3.new(0,1,0)))
- local neckAngle = angle
- -- Limit how much the head can tilt down. Too far and the head looks unnatural
- if math.deg(neckAngle) > 110 then
- neckAngle = math.rad(110)
- end
- neck.C0 = CFrame.new(0,1,0) * CFrame.Angles(math.pi - neckAngle,math.pi,0)
- -- Calculate horizontal rotation
- local arm = player.Character:FindFirstChild("Right Arm")
- local fromArmPos = torso.Position + torso.CFrame:vectorToWorldSpace(Vector3.new(
- torso.Size.X/2 + arm.Size.X/2, torso.Size.Y/2 - arm.Size.Z/2, 0))
- local toMouseArm = ((mousePosition - fromArmPos) * Vector3.new(1,0,1)).unit
- local look = (torso.CFrame.lookVector * Vector3.new(1,0,1)).unit
- local lateralAngle = math.acos(toMouseArm:Dot(look))
- -- Check for rogue math
- if tostring(lateralAngle) == "-1.#IND" then
- lateralAngle = 0
- end
- -- Handle case where character is sitting down
- if player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
- local cross = torso.CFrame.lookVector:Cross(toMouseArm)
- if lateralAngle > math.pi/2 then
- lateralAngle = math.pi/2
- end
- if cross.Y < 0 then
- lateralAngle = -lateralAngle
- end
- end
- -- Turn shoulder to point to mouse
- shoulder.C0 = CFrame.new(1,0.5,0) * CFrame.Angles(math.pi/2 - angle,math.pi/2 + lateralAngle,0)
- -- If not sitting then aim torso laterally towards mouse
- if not amISitting(player.Character) then
- torso.CFrame = CFrame.new(torso.Position, torso.Position + (Vector3.new(
- mousePosition.X, torso.Position.Y, mousePosition.Z)-torso.Position).unit)
- end
- end
- end
- -- Function to bind to render stepped if player is on PC
- local function pcFrame()
- frame(mouse.Hit.p)
- end
- -- Function to bind to touch moved if player is on mobile
- local function mobileFrame(touch, processed)
- -- Check to see if the touch was on a UI element. If so, we don't want to update anything
- if not processed then
- -- Calculate touch position in world space. Uses Stravant's ScreenSpace Module script
- -- to create a ray from the camera.
- local test = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1)
- local nearPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1))
- nearPos = game.Workspace.CurrentCamera.CoordinateFrame.p - nearPos
- local farPos = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y,50)
- farPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(farPos) * -1
- if farPos.magnitude > 900 then
- farPos = farPos.unit * 900
- end
- local ray = Ray.new(nearPos, farPos)
- local part, pos = game.Workspace:FindPartOnRay(ray, player.Character)
- -- if a position was found on the ray then update the character's rotation
- if pos then
- frame(pos)
- end
- end
- end
- local function OnActivated()
- local myModel = player.Character
- if Tool.Enabled and myModel and myModel:FindFirstChild('Humanoid') and myModel.Humanoid.Health > 0 then
- Tool.Enabled = false
- game.ReplicatedStorage.ROBLOX_RocketFireEvent:FireServer(mouse.Hit.p)
- wait(2)
- Tool.Enabled = true
- end
- end
- local oldIcon = nil
- -- Function to bind to equip event
- local function equip()
- local torso = player.Character.Torso
- -- Setup joint variables
- neck = torso.Neck
- oldNeckC0 = neck.C0
- shoulder = torso:FindFirstChild("Right Shoulder")
- oldShoulderC0 = shoulder.C0
- -- Remember old mouse icon and update current
- oldIcon = mouse.Icon
- mouse.Icon = "http://www.roblox.com/asset/?id=79658449"
- -- Bind TouchMoved event if on mobile. Otherwise connect to renderstepped
- if userInputService.TouchEnabled then
- connection = userInputService.TouchMoved:connect(mobileFrame)
- else
- connection = render:connect(pcFrame)
- end
- -- Bind TouchStarted and TouchEnded. Used to determine if character should rotate
- -- during touch input
- userInputService.TouchStarted:connect(function(touch, processed)
- mobileShouldTrack = not processed
- end)
- userInputService.TouchEnded:connect(function(touch, processed)
- mobileShouldTrack = false
- end)
- -- If game uses filtering enabled then need to update server while tool is
- -- held by character.
- if workspace.FilteringEnabled then
- while connection and connection.Connected do
- wait()
- game.ReplicatedStorage.ROBLOX_RocketUpdateEvent:FireServer(neck.C0, shoulder.C0)
- end
- end
- end
- -- Function to bind to Unequip event
- local function unequip()
- if connection then connection:disconnect() end
- mouse.Icon = oldIcon
- neck.C0 = oldNeckC0
- shoulder.C0 = oldShoulderC0
- end
- -- Bind tool events
- Tool.Equipped:connect(equip)
- Tool.Unequipped:connect(unequip)
- Tool.Activated:connect(OnActivated)
- end))
- Configuration8.Name = "Configurations"
- Configuration8.Parent = Tool0
- NumberValue9.Name = "AttackCooldown"
- NumberValue9.Parent = Configuration8
- NumberValue9.Value = 3
- IntValue10.Name = "Damage"
- IntValue10.Parent = Configuration8
- IntValue10.Value = 60
- NumberValue11.Name = "ReloadTime"
- NumberValue11.Parent = Configuration8
- NumberValue11.Value = 1
- IntValue12.Name = "BlastForce"
- IntValue12.Parent = Configuration8
- IntValue12.Value = 1000
- IntValue13.Name = "BlastRadius"
- IntValue13.Parent = Configuration8
- IntValue13.Value = 8
- IntValue14.Name = "RocketSpeed"
- IntValue14.Parent = Configuration8
- IntValue14.Value = 60
- 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