Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- > Made by wulfbug9
- -- > Simple rocket launcher.
- function Random(R) return (math.random()-.5)*2*(R or 1) end
- function Create(Data)
- local Obj = Instance.new(Data[1])
- table.remove(Data,1)
- for i,v in pairs(Data)do
- Obj[i] = v
- end
- return Obj
- end
- function C(Func,Args)
- return coroutine.resume(coroutine.create(Func),unpack(Args or {}))
- end
- ------------------------------------------------------------------------
- function Part(Parent,Size,CFrame,Anchored,CanCollide,Colour,Trans,Material)
- local Part = Instance.new("Part",Parent)
- Part.FormFactor = "Custom"
- Part.Anchored = Anchored
- Part.CanCollide = CanCollide
- Part.Size = Size
- Part.CFrame = CFrame
- Part.BrickColor = BrickColor.new(Colour)
- Part.Transparency = Trans
- Part.Material = Material
- Part.TopSurface,Part.BottomSurface = 0,0
- Part:BreakJoints()
- Part.Velocity = Vector3.new(0,0,0)
- Part.Locked = true
- return Part
- end
- function Weld(p1,p2,c0,c1)
- local w = Instance.new("Weld",p1)w.Part0 = p1;w.Part1 = p2
- w.C0,w.C1 = c0 or CFrame.new(),c1 or CFrame.new()
- return w
- end
- Tween = {}
- function slerp(a,b,c)return (1-c)*a+(c*b)end
- function cslerp(start,destination,increment)
- local c1 = {start.X,start.Y,start.Z,start:toEulerAnglesXYZ()}
- local c2 = {destination.X,destination.Y,destination.Z,destination:toEulerAnglesXYZ()}
- for i,v in pairs(c1)do c1[i] = slerp(v,c2[i],increment)end
- return CFrame.new(c1[1],c1[2],c1[3])*CFrame.Angles(c1[4],c1[5],c1[6])
- end
- c0 = {
- ls = CFrame.new(-.5,0.5,0);
- rs = CFrame.new(.5,0.5,0);
- }
- c1 = {
- ls = CFrame.new(0.5,0.5,0);
- rs = CFrame.new(-0.5,0.5,0);
- }
- ------------------------------------------------------------------------
- Player = game:service("Players").LocalPlayer
- Mouse = Player:GetMouse()
- local Character
- repeat wait() Character = Player.Character until Character
- Shooting = false
- asset = "rbxassetid://"
- meshes = {["blast"] = 20329976,["ring"] = 3270017,["spike"] = 1033714,["cone"] = 1082802,["crown"] = 20329976,["cloud"] = 1095708,["diamond"] = 9756362}
- Camera = workspace.CurrentCamera
- RenderStepped = game:service("RunService").RenderStepped
- Torso = Character:WaitForChild("Torso")
- RArm = Character:WaitForChild("Right Arm")
- LArm = Character:WaitForChild("Left Arm")
- RLeg = Character:WaitForChild("Right Leg")
- LLeg = Character:WaitForChild("Left Leg")
- Head = Character:WaitForChild("Head")
- HRP = Character:WaitForChild("HumanoidRootPart")
- RS = Weld(Torso,RArm,c0.rs,c1.rs)
- LS = Weld(Torso,LArm,c0.ls,c1.ls)
- BG = Instance.new("BodyGyro",HRP)
- BG.maxTorque = Vector3.new(1,1,1)*10^6
- BG.P = 10^4
- local Tip
- ------------------------------------------------------------------------
- function Smoke(Origin)
- local Part = Part(Character,Vector3.new(5,5,5),Origin*CFrame.new(Random(1),Random(1),Random(1)),true,false,"Grey",1,"Plastic")
- local Mesh = Create{"SpecialMesh",Parent = Part,MeshType = "Sphere"}
- C(function(P,M)
- for i=1,0,-.1 do
- P.CFrame = P.CFrame+(Origin*CFrame.Angles(0,math.pi,0)).lookVector
- P.Transparency = i
- wait()
- end
- for i=0,1,.025 do
- P.CFrame = P.CFrame+(Origin*CFrame.Angles(0,math.pi,0)).lookVector
- P.Transparency = i
- M.Scale = M.Scale - Vector3.new(.025,.025,.025)
- wait()
- end
- P:Destroy()
- end,{Part,Mesh})
- end
- function findNearbyHumans(Origin,Distance)
- local Found = {}
- for i,v in pairs(workspace:children()) do
- local Human;
- local Torso;
- if v:FindFirstChild("Torso") and v~=Character then
- Torso = v:FindFirstChild("Torso")
- for _,h in pairs(v:children())do if h:IsA("Humanoid") then Human = h end end
- if Human then
- local D = (Origin.p - Torso.CFrame.p).magnitude
- if Distance >= D then
- table.insert(Found,{v,Torso,Human})
- end
- end
- end
- end
- return Found
- end
- function EXPLOD(Origin,Colour,Size)
- local Part = Part(Character,Vector3.new(Size,Size,Size),Origin*CFrame.new(Random(1),Random(1),Random(1)),true,false,Colour,1,"Plastic")
- local Mesh = Create{"SpecialMesh",Parent = Part,MeshType = "Sphere"}
- C(function(P,M)
- for i=1,0,-.1 do
- P.Transparency = i
- wait()
- end
- for i=0,1,.05 do
- P.Transparency = i
- M.Scale = M.Scale - Vector3.new(.05,.05,.05)
- wait()
- end
- P:Destroy()
- end,{Part,Mesh})
- end
- function Shoot(start,dmg)
- dmg = dmg or 15
- local vel = start.lookVector
- local p = Part(Character,Vector3.new(.5,.5,3),start,true,false,"Grey",0,"DiamondPlate")
- local num = 0
- local ign = Character:children()
- local connect
- connect = RenderStepped:connect(function()
- num = num + 1
- local pp = p.Position
- local h,po
- vel = vel - Vector3.new(0,math.min(999.5,vel.magnitude/500),0)
- repeat
- local r = Ray.new(pp,vel.unit*math.min(999.5,vel.magnitude/100+2))
- h,po = workspace:FindPartOnRayWithIgnoreList(r,ign)
- if h then
- if h.CanCollide then break
- else table.insert(ign,h)h = nil
- end
- else break
- end
- until false
- if num%5==0 then Smoke(p.CFrame) end
- p.CFrame = CFrame.new(po,po+vel)
- if h or num > 300 then
- local cf = p.CFrame
- for i,v in pairs(findNearbyHumans(cf,10))do
- v[3].Health = v[3].Health - 25
- v[3].Sit = true
- v[2].Velocity = -(CFrame.new(v[2].CFrame.p,cf.p)).lookVector*100
- end
- local colurz = {"Bright red","Bright yellow","Bright orange"}
- for i=1,math.random(3,6) do
- EXPLOD(cf,colurz[math.random(1,#colurz)],math.random(10,20))
- end
- p:Destroy()
- connect:disconnect()
- end
- end)
- end
- function TakeShot()
- Shooting = true
- wait()
- Shoot(Tip.CFrame*CFrame.Angles(0,-math.pi/2,0))
- Torso.Velocity = -(Tip.CFrame*CFrame.Angles(0,-math.pi/2,0)).lookVector*100
- wait(2)
- Shooting = false
- end
- ------------------------------------------------------------------------
- pcall(function()Character:FindFirstChild("Rocket"):Destroy()end)
- Model = Create{"Model",Parent = Character,Name = "Rocket"}
- Handle = Part(Model,Vector3.new(2.5,0.5,0.5),Torso.CFrame,false,false,"Grey",0,"Plastic")
- HandleM = Create{"SpecialMesh",Parent = Handle,MeshType = "Cylinder"}
- HandleW = Weld(RArm,Handle,CFrame.new(0,0,-.75)*CFrame.Angles(math.pi/2,math.pi/2,math.pi))
- Tip = Part(Model,Vector3.new(.5,0.5,0.5),Torso.CFrame,false,false,"Bright red",0,"Plastic")
- TipM = Create{"SpecialMesh",Parent = Tip,MeshType = "Cylinder"}
- TipW = Weld(Handle,Tip,CFrame.new(2.5/2 + .25,0,0))
- Trig = Part(Model,Vector3.new(0.25,.75,.4),Torso.CFrame,false,false,"Grey",0,"Plastic")
- TrigW = Weld(Handle,Trig,CFrame.new(-1,-.25,0)*CFrame.Angles(0,0,-math.pi/8))
- Trig2 = Part(Model,Vector3.new(0.25,.75,.4),Torso.CFrame,false,false,"Grey",0,"Plastic")
- Trig2W = Weld(Handle,Trig2,CFrame.new(1,-.25,0))
- End = Part(Model,Vector3.new(.5,0.6,0.6),Torso.CFrame,false,false,"Black",0,"Plastic")
- EndM = Create{"SpecialMesh",Parent = End,MeshType = "Cylinder"}
- EndW = Weld(Handle,End,CFrame.new(-2.5/2 + .2,0,0))
- ------------------------------------------------------------------------
- Mouse.Button1Down:connect(function()
- if Shooting then return end
- TakeShot()
- end)
- RenderStepped:connect(function()
- RS.C0 = c0.rs*CFrame.Angles(Torso.CFrame:toObjectSpace(CFrame.new((Torso.CFrame*RS.C0).p,Mouse.Hit.p)*CFrame.Angles(math.pi/2,0,0)):toEulerAnglesXYZ())
- LS.C0 = c0.ls*CFrame.Angles(Torso.CFrame:toObjectSpace(CFrame.new((Torso.CFrame*LS.C0).p,Mouse.Hit.p)*CFrame.Angles(math.pi/2,0,math.pi/4)):toEulerAnglesXYZ())
- BG.cframe = CFrame.new(CFrame.new(HRP.CFrame.x,HRP.CFrame.y,HRP.CFrame.z).p,CFrame.new(Camera.CoordinateFrame.x,HRP.CFrame.y,Camera.CoordinateFrame.z).p)*CFrame.Angles(0,math.pi,0)
- end)
Add Comment
Please, Sign In to add comment