Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Created with ttyyuu12345's compiler
- --Errors: TouchTransmitter,LocalScript,ModuleScript
- Create = function(itemClass,tabl)
- local item = Instance.new(itemClass)
- for i,v in pairs(tabl) do
- local a,b = ypcall(function() return item[i] end)
- if a then
- item[i] = tabl[i]
- end
- end
- return item
- end
- function runDummyScript(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 = Create("Tool",{
- ["Name"] = "RocketLauncher",
- ["Parent"] = mas,
- ["TextureId"] = "http://www.roblox.com/asset/?id=90021376",
- ["GripForward"] = Vector3.new(1, -0, -0),
- ["GripPos"] = Vector3.new(0.699999988, 0, -0.5),
- ["GripRight"] = Vector3.new(0, -1, 0),
- ["GripUp"] = Vector3.new(0, 0, 1),
- ["CanBeDropped"] = false,
- })
- o2 = Create("Part",{
- ["Name"] = "Handle",
- ["Parent"] = o1,
- ["Rotation"] = Vector3.new(-89.9963913, 0, -0),
- ["CFrame"] = CFrame.new(0, 0, 0, 1, 0, 0, 0, 6.30170107e-005, 1.00000024, 0, -1.00000024, 6.30170107e-005),
- ["CanCollide"] = false,
- ["FormFactor"] = Enum.FormFactor.Custom,
- ["Size"] = Vector3.new(4.92000628, 0.740000546, 0.839999795),
- ["BottomSurface"] = Enum.SurfaceType.Smooth,
- ["TopSurface"] = Enum.SurfaceType.Smooth,
- })
- o3 = Create("SpecialMesh",{
- ["Parent"] = o2,
- ["MeshId"] = "rbxasset://fonts/rocketlauncher.mesh",
- ["Scale"] = Vector3.new(0.75, 0.75, 0.75),
- ["TextureId"] = "rbxasset://textures/rocketlaunchertex.png",
- ["MeshType"] = Enum.MeshType.FileMesh,
- })
- o5 = Create("Script",{
- ["Parent"] = o1,
- })
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(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.Position = rocketClone.Position
- 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,o5)
- end))
- o6 = Create("Sound",{
- ["Name"] = "Boom",
- ["Parent"] = o5,
- ["SoundId"] = "rbxasset://sounds/collide.wav",
- ["Volume"] = 1,
- })
- o7 = Create("Sound",{
- ["Name"] = "Swoosh",
- ["Parent"] = o5,
- ["SoundId"] = "rbxasset://sounds/Rocket whoosh 01.wav",
- ["Volume"] = 0.69999998807907,
- ["Looped"] = true,
- })
- o8 = Create("Script",{
- ["Name"] = "Rocket",
- ["Parent"] = o5,
- })
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(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,o8)
- end))
- o10 = Create("Configuration",{
- ["Name"] = "Configurations",
- ["Parent"] = o1,
- })
- o11 = Create("NumberValue",{
- ["Name"] = "AttackCooldown",
- ["Parent"] = o10,
- ["Value"] = 3,
- })
- o12 = Create("IntValue",{
- ["Name"] = "Damage",
- ["Parent"] = o10,
- ["Value"] = 60,
- })
- o13 = Create("NumberValue",{
- ["Name"] = "ReloadTime",
- ["Parent"] = o10,
- ["Value"] = 1,
- })
- o14 = Create("IntValue",{
- ["Name"] = "BlastForce",
- ["Parent"] = o10,
- ["Value"] = 1000,
- })
- o15 = Create("IntValue",{
- ["Name"] = "BlastRadius",
- ["Parent"] = o10,
- ["Value"] = 8,
- })
- o16 = Create("IntValue",{
- ["Name"] = "RocketSpeed",
- ["Parent"] = o10,
- ["Value"] = 60,
- })
- mas.Parent = workspace
- mas:MakeJoints()
- local mas1 = mas:GetChildren()
- for i=1,#mas1 do
- mas1[i].Parent = script
- 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