Advertisement
IAmBW

Dragon

Mar 21st, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.38 KB | None | 0 0
  1. MainColor = "Bright blue"
  2. Name = "IAmBW"
  3.  
  4. Plrs = game:GetService("Players")
  5.  
  6. me = Plrs[Name]
  7. char = me.Character
  8. Modelname = "xDragon"
  9. PetName = "xDragon"
  10. Toolname = "Dragon"
  11. Surfaces = {"FrontSurface", "BackSurface", "TopSurface", "BottomSurface", "LeftSurface", "RightSurface"}
  12. necko = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  13. selected = false
  14. Hurt = false
  15. Deb = true
  16. Able = true
  17. Prop = {Damage = 30}
  18.  
  19. ToolIcon = ""
  20. MouseIc = ""
  21. MouseDo = ""
  22.  
  23. Add = {
  24.     Sphere = function(P)
  25.         local m = Instance.new("SpecialMesh",P)
  26.         m.MeshType = "Sphere"
  27.         return m
  28.     end,
  29.     BF = function(P)
  30.         local bf = Instance.new("BodyForce",P)
  31.         bf.force = Vector3.new(0, P:GetMass()*187, 0)
  32.         return bf
  33.     end,
  34.     BP = function(P)
  35.         local bp = Instance.new("BodyPosition",P)
  36.         bp.maxForce = Vector3.new(math.huge, 0, math.huge)
  37.         bp.P = 14000
  38.         return bp
  39.     end,
  40.     BG = function(P)
  41.         local bg = Instance.new("BodyGyro",P)
  42.         bg.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  43.         bg.P = 14000
  44.         return bg
  45.     end,
  46.     Mesh = function(P, ID, x, y, z)
  47.         local m = Instance.new("SpecialMesh")
  48.         m.MeshId = ID
  49.         m.Scale = Vector3.new(x, y, z)
  50.         m.Parent = P
  51.         return m
  52.     end,
  53.     Sound = function(P, ID, vol, pitch)
  54.         local s = Instance.new("Sound")
  55.         s.SoundId = ID
  56.         s.Volume = vol
  57.         s.Pitch = pitch
  58.         s.Parent = P
  59.         return s
  60.     end
  61. }
  62.  
  63. function find(tab, arg)
  64.     local ah = nil
  65.     for i,v in pairs(tab) do
  66.         if v == arg then
  67.             ah = v
  68.         end
  69.     end
  70.     return ah
  71. end
  72.  
  73. function getAllParts(from)
  74.     local t = {}
  75.     function getParts(where)
  76.         for i, v in pairs(where:children()) do
  77.             if v:IsA("BasePart") then
  78.                 if v.Parent ~= char and v.Parent.Parent ~= char then
  79.                     table.insert(t, v)
  80.                 end
  81.             end
  82.             getParts(v)
  83.         end
  84.     end
  85.     getParts(workspace)
  86.     return t
  87. end
  88.  
  89. function RayCast(pos1, pos2, maxDist, forward)
  90.     local list = getAllParts(workspace)
  91.     local pos0 = pos1
  92.     for dist = 1, maxDist, forward do
  93.         pos0 = (CFrame.new(pos1, pos2) * CFrame.new(0, 0, -dist)).p
  94.         for _, v in pairs(list) do
  95.             local pos3 = v.CFrame:pointToObjectSpace(pos0)
  96.             local s = v.Size
  97.             if pos3.x > -(s.x/2) and pos3.x < (s.x/2) and pos3.y > -(s.y/2) and pos3.y < (s.y/2) and pos3.z > -(s.z/2) and pos3.x < (s.z/2) and v.CanCollide == true then
  98.                 return pos0, v
  99.             end
  100.         end
  101.     end
  102.     return pos0, nil
  103. end
  104.  
  105. function Part(Parent, Anchor, Collide, Tran, Ref, Color, X, Y, Z, Break)
  106.     local p = Instance.new("Part")
  107.     p.formFactor = "Custom"
  108.     p.Anchored = Anchor
  109.     p.CanCollide = Collide
  110.     p.Transparency = Tran
  111.     p.Reflectance = Ref
  112.     p.BrickColor = BrickColor.new(Color)
  113.     for _, Surf in pairs(Surfaces) do
  114.         p[Surf] = "Smooth"
  115.     end
  116.     p.Size = Vector3.new(X, Y, Z)
  117.     if Break then
  118.         p:BreakJoints()
  119.     else p:MakeJoints() end
  120.     p.Parent = Parent
  121.     return p
  122. end
  123.  
  124. function Weld(p0, p1, x, y, z, a, b, c)
  125.     local w = Instance.new("Weld")
  126.     w.Parent = p0
  127.     w.Part0 = p0
  128.     w.Part1 = p1
  129.     w.C1 = CFrame.new(x,y,z) * CFrame.Angles(a,b,c)
  130.     return w
  131. end
  132.  
  133. function ComputePos(pos1, pos2)
  134.     local pos3 = Vector3.new(pos2.x, pos1.y, pos2.z)
  135.     return CFrame.new(pos1, pos3)
  136. end
  137.  
  138. function getHumanoid(c)
  139.     local h = nil
  140.     for i,v in pairs(c:children()) do
  141.         if v:IsA("Humanoid") and c ~= char then
  142.             if v.Health > 0 then
  143.                 h = v
  144.             end
  145.         end
  146.     end
  147.     return h
  148. end
  149.  
  150. for i,v in pairs(char:children()) do
  151.     if v.Name == Modelname or v.Name == PetName then
  152.         v:remove()
  153.     end
  154. end
  155.  
  156. torso = char.Torso
  157. neck = torso.Neck
  158. hum = char.Humanoid
  159. Rarm = char["Right Arm"]
  160. Larm = char["Left Arm"]
  161. Rleg = char["Right Leg"]
  162. Lleg = char["Left Leg"]
  163.  
  164. hc = Instance.new("Humanoid")
  165. hc.Health = 0
  166. hc.MaxHealth = 0
  167.  
  168. slash = Add.Sound(nil, "rbxasset://sounds//swordslash.wav", 0.9, 0.8)
  169. hitsound = Add.Sound(nil, "http://www.roblox.com/asset/?id=2801263", 0.7, 0.6)
  170. charge = Add.Sound(nil, "http://www.roblox.com/asset/?id=2101137", 0.8, 0.65)
  171. boom = Add.Sound(nil, "http://www.roblox.com/asset/?id=2691586", 0.8, 0.3)
  172. smashsound = Add.Sound(nil, "http://www.roblox.com/asset/?id=2692806", 0.8, 0.35)
  173. boomboom = Add.Sound(nil, "http://www.roblox.com/asset/?id=2760979", 1, 0.18)
  174.  
  175. function PlaySound(sound, pitch, vol)
  176.     local s = sound:clone()
  177.     if pitch ~= nil then
  178.         if tonumber(pitch) then
  179.             s.Pitch = tonumber(pitch)
  180.         end
  181.     end
  182.     if vol ~= nil then
  183.         if tonumber(vol) then
  184.             s.Volume = tonumber(vol)
  185.         end
  186.     end
  187.     s.Parent = torso
  188.     s.PlayOnRemove = true
  189.     coroutine.resume(coroutine.create(function()
  190.         wait()
  191.         s:remove()
  192.     end))
  193. end
  194.  
  195. Mo = Instance.new("Model")
  196. Mo.Name = Modelname
  197.  
  198. RABrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  199. LABrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  200. RLBrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  201. LLBrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  202.  
  203. RABW = Weld(torso, RABrick, -1.5, -0.5, 0, 0, 0, 0)
  204. LABW = Weld(torso, LABrick, 1.5, -0.5, 0, 0, 0, 0)
  205. RLBW = Weld(torso, RLBrick, -0.5, 1.2, 0, 0, 0, 0)
  206. LLBW = Weld(torso, LLBrick, 0.5, 1.2, 0, 0, 0, 0)
  207.  
  208. RAW = Weld(RABrick, nil, 0, 0.5, 0, 0, 0, 0)
  209. LAW = Weld(LABrick, nil, 0, 0.5, 0, 0, 0, 0)
  210. RLW = Weld(RLBrick, nil, 0, 0.8, 0, 0, 0, 0)
  211. LLW = Weld(LLBrick, nil, 0, 0.8, 0, 0, 0, 0)
  212.  
  213. HB = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  214. HBW = Weld(Rarm, HB, 0, 1, 0, 0, 0, 0)
  215. HW = Weld(HB, nil, 0, -1.3, 0, math.pi/2, 0, 0)
  216.  
  217. TH = Weld(torso, nil, -0.8, 0.4, -0.4, 0, math.pi/2, math.rad(80))
  218.  
  219. RAWStand, LAWStand, RLWStand, LLWStand, HWStand = nil
  220.  
  221. --handle = Part(Mo, false, false, 0, 0, GuitarColour, 0.6, 1.5, 1.5, true)
  222.  
  223. Pet = Instance.new("Model")
  224. Pet.Name = PetName
  225.  
  226. petbody = Part(Pet, false, true, 0, 0, MainColor, 3, 2.6, 6, true)
  227. Add.Sphere(petbody)
  228. petbody.CFrame = torso.CFrame * CFrame.new(4, 0, 0)
  229.  
  230. bodytrim = Part(Pet, false, true, 0, 0, "Cool yellow", 2.7, 2.4, 5.4, true)
  231. Add.Sphere(bodytrim)
  232. Weld(petbody, bodytrim, 0, 0.25, 0, 0, 0, 0)
  233.  
  234. neckplace = Part(Pet, false, false, 0, 0, "Cool yellow", 0.1, 0.1, 0.1, true)
  235. Weld(petbody, neckplace, 0, -0.2, 2.6, 0, 0, 0)
  236.  
  237. Mo.Parent = char
  238. Pet.Parent = char
  239. TH.Part1 = handle
  240.  
  241. if script.Parent.className ~= "HopperBin" then
  242.     h = Instance.new("HopperBin",me.Backpack)
  243.     h.Name = Toolname
  244.     h.TextureId = ToolIcon
  245.     script.Parent = h
  246. end
  247.  
  248. bin = script.Parent
  249.  
  250. function detach(bool)
  251.     LLW.C0 = CFrame.new(0, 0, 0)
  252.     RLW.C0 = CFrame.new(0, 0, 0)
  253.     LAW.C0 = CFrame.new(0,0,0)
  254.     RAW.C0 = CFrame.new(0, 0, 0)
  255.     if bool then
  256.         LLW.Part1 = nil
  257.         RLW.Part1 = nil
  258.         RAW.Part1 = nil
  259.         LAW.Part1 = nil
  260.     end
  261. end
  262.  
  263. function attach()
  264.     RAW.Part1 = Rarm
  265.     LAW.Part1 = Larm
  266.     RLW.Part1 = Rleg
  267.     LLW.Part1 = Lleg
  268. end
  269.  
  270. function normal()
  271.     neck.C0 = NeckStand
  272.     RAW.C0 = RAWStand
  273.     LAW.C0 = LAWStand
  274.     RLW.C0 = RLWStand
  275.     LLW.C0 = LLWStand
  276.     RAW.C1 = CFrame.new(0, 0.5, 0)
  277.     LAW.C1 = CFrame.new(0, 0.5, 0)
  278.     RLW.C1 = CFrame.new(0, 0.8, 0)
  279.     LLW.C1 = CFrame.new(0, 0.8, 0)
  280.     HW.C0 = HWStand
  281. end
  282.  
  283. function idleanim()
  284.     attach()
  285.     for i = 0, 1, 0.03 do
  286.         RAW.C0 = RAWStand * CFrame.Angles(0, 0, 0)
  287.         LAW.C0 = LAWStand * CFrame.Angles(0, 0, 0)
  288.         RLW.C0 = RLWStand * CFrame.Angles(0, 0, 0)
  289.         LLW.C0 = LLWStand * CFrame.Angles(0, 0, 0)
  290.         neck.C0 = NeckStand * CFrame.Angles(0, 0, 0)
  291.         if selected == false or torso.Velocity.magnitude > 2 or Able == false then break end
  292.         wait()
  293.     end
  294.     wait()
  295.     for i = 1, 0, -0.02 do
  296.         RAW.C0 = RAWStand * CFrame.Angles(0, 0, 0)
  297.         LAW.C0 = LAWStand * CFrame.Angles(0, 0, 0)
  298.         RLW.C0 = RLWStand * CFrame.Angles(0, 0, 0)
  299.         LLW.C0 = LLWStand * CFrame.Angles(0, 0, 0)
  300.         neck.C0 = NeckStand * CFrame.Angles(0, 0, 0)
  301.         if selected == false or torso.Velocity.magnitude > 2 or Able == false then break end
  302.         wait()
  303.     end
  304.     normal()
  305. end
  306.  
  307. function runanim()
  308.     RLW.Part1 = nil
  309.     LLW.Part1 = nil
  310. end
  311.  
  312. coroutine.resume(coroutine.create(function()
  313.     while true do
  314.         wait()
  315.         if selected and Able == true then
  316.             if torso.Velocity.magnitude < 2 then
  317.                 --idleanim()
  318.                 wait()
  319.             else
  320.                 --runanim()
  321.                 wait()
  322.             end
  323.         end
  324.     end
  325. end))
  326.  
  327. function selectanim()
  328.     attach()
  329.     if RAWStand == nil then
  330.         RAWStand = RAW.C0
  331.         LAWStand = LAW.C0
  332.         RLWStand = RLW.C0
  333.         LLWStand = LLW.C0
  334.         HWStand = HW.C0
  335.     end
  336.     normal()
  337. end
  338.  
  339. function deselanim()
  340.     neck.C0 = necko
  341.     detach(true)
  342. end
  343.  
  344. function select(mouse)
  345.     selectanim()
  346.     selected = true
  347.     mouse.KeyDown:connect(function(key)
  348.         key = key:lower()
  349.     end)
  350.     mouse.Button1Down:connect(function()
  351.     end)
  352. end
  353.  
  354. function deselect(mouse)
  355.     selected = false
  356.     deselanim()
  357. end
  358.  
  359. bin.Selected:connect(select)
  360. bin.Deselected:connect(deselect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement