Advertisement
proff001

Guitar Script

Sep 30th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.07 KB | None | 0 0
  1. GuitarColour = "Medium blue"
  2. me = game.Players.LocalPlayer
  3. char = me.Character
  4. Modelname = "xGuitar"
  5. Toolname = "Guitar"
  6. Surfaces = {"FrontSurface", "BackSurface", "TopSurface", "BottomSurface", "LeftSurface", "RightSurface"}
  7. necko = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  8. selected = false
  9. Hurt = false
  10. Deb = true
  11. Able = true
  12. Prop = {Damage = 30}
  13. volume = 0.75
  14. ToolIcon = ""
  15. MouseIc = ""
  16. MouseDo = ""
  17. Add = {
  18. Sphere = function(P)
  19. local m = Instance.new("SpecialMesh",P)
  20. m.MeshType = "Sphere"
  21. return m
  22. end,
  23. BF = function(P)
  24. local bf = Instance.new("BodyForce",P)
  25. bf.force = Vector3.new(0, P:GetMass()*187, 0)
  26. return bf
  27. end,
  28. BP = function(P)
  29. local bp = Instance.new("BodyPosition",P)
  30. bp.maxForce = Vector3.new(math.huge, 0, math.huge)
  31. bp.P = 14000
  32. return bp
  33. end,
  34. BG = function(P)
  35. local bg = Instance.new("BodyGyro",P)
  36. bg.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  37. bg.P = 14000
  38. return bg
  39. end,
  40. Mesh = function(P, ID, x, y, z)
  41. local m = Instance.new("SpecialMesh")
  42. m.MeshId = ID
  43. m.Scale = Vector3.new(x, y, z)
  44. m.Parent = P
  45. return m
  46. end,
  47. Sound = function(P, ID, vol, pitch)
  48. local s = Instance.new("Sound")
  49. s.SoundId = ID
  50. s.Volume = vol
  51. s.Pitch = pitch
  52. s.Parent = P
  53. return s
  54. end
  55. }
  56. function find(tab, arg)
  57. local ah = nil
  58. for i,v in pairs(tab) do
  59. if v == arg then
  60. ah = v
  61. end
  62. end
  63. return ah
  64. end
  65. function getAllParts(from)
  66. local t = {}
  67. function getParts(where)
  68. for i, v in pairs(where:children()) do
  69. if v:IsA("BasePart") then
  70. if v.Parent ~= char and v.Parent.Parent ~= char then
  71. table.insert(t, v)
  72. end
  73. end
  74. getParts(v)
  75. end
  76. end
  77. getParts(workspace)
  78. return t
  79. end
  80. function RayCast(pos1, pos2, maxDist, forward)
  81. local list = getAllParts(workspace)
  82. local pos0 = pos1
  83. for dist = 1, maxDist, forward do
  84. pos0 = (CFrame.new(pos1, pos2) * CFrame.new(0, 0, -dist)).p
  85. for _, v in pairs(list) do
  86. local pos3 = v.CFrame:pointToObjectSpace(pos0)
  87. local s = v.Size
  88. 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
  89. return pos0, v
  90. end
  91. end
  92. end
  93. return pos0, nil
  94. end
  95. function Part(Parent, Anchor, Collide, Tran, Ref, Color, X, Y, Z, Break)
  96. local p = Instance.new("Part")
  97. p.formFactor = "Custom"
  98. p.Anchored = Anchor
  99. p.CanCollide = Collide
  100. p.Transparency = Tran
  101. p.Reflectance = Ref
  102. p.BrickColor = BrickColor.new(Color)
  103. for _, Surf in pairs(Surfaces) do
  104. p[Surf] = "Smooth"
  105. end
  106. p.Size = Vector3.new(X, Y, Z)
  107. if Break then
  108. p:BreakJoints()
  109. else p:MakeJoints() end
  110. p.Parent = Parent
  111. return p
  112. end
  113. function Weld(p0, p1, x, y, z, a, b, c)
  114. local w = Instance.new("Weld")
  115. w.Parent = p0
  116. w.Part0 = p0
  117. w.Part1 = p1
  118. w.C1 = CFrame.new(x,y,z) * CFrame.Angles(a,b,c)
  119. return w
  120. end
  121. function ComputePos(pos1, pos2)
  122. local pos3 = Vector3.new(pos2.x, pos1.y, pos2.z)
  123. return CFrame.new(pos1, pos3)
  124. end
  125. function getHumanoid(c)
  126. local h = nil
  127. for i,v in pairs(c:children()) do
  128. if v:IsA("Humanoid") and c ~= char then
  129. if v.Health > 0 then
  130. h = v
  131. end
  132. end
  133. end
  134. return h
  135. end
  136. for i,v in pairs(char:children()) do
  137. if v.Name == Modelname then
  138. v:remove()
  139. end
  140. end
  141. torso = char.Torso
  142. neck = torso.Neck
  143. hum = char.Humanoid
  144. Rarm = char["Right Arm"]
  145. Larm = char["Left Arm"]
  146. Rleg = char["Right Leg"]
  147. Lleg = char["Left Leg"]
  148. hc = Instance.new("Humanoid")
  149. hc.Health = 0
  150. hc.MaxHealth = 0
  151. slash = Add.Sound(nil, "rbxasset://sounds//swordslash.wav", 0.9, 0.8)
  152. hitsound = Add.Sound(nil, "http://www.roblox.com/asset/?id=2801263", 0.7, 0.6)
  153. charge = Add.Sound(nil, "http://www.roblox.com/asset/?id=2101137", 0.8, 0.65)
  154. boom = Add.Sound(nil, "http://www.roblox.com/asset/?id=2691586", 0.8, 0.3)
  155. smashsound = Add.Sound(nil, "http://www.roblox.com/asset/?id=2692806", 0.8, 0.35)
  156. boomboom = Add.Sound(nil, "http://www.roblox.com/asset/?id=2760979", 1, 0.18)
  157. GSound = Add.Sound(workspace, "http://www.roblox.com/asset/?id=1089403", 0.75, 1)
  158. Mo = Instance.new("Model")
  159. Mo.Name = Modelname
  160. RABrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  161. LABrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  162. RLBrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  163. LLBrick = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  164. RABW = Weld(torso, RABrick, -1.5, -0.5, 0, 0, 0, 0)
  165. LABW = Weld(torso, LABrick, 1.5, -0.5, 0, 0, 0, 0)
  166. RLBW = Weld(torso, RLBrick, -0.5, 1.2, 0, 0, 0, 0)
  167. LLBW = Weld(torso, LLBrick, 0.5, 1.2, 0, 0, 0, 0)
  168. RAW = Weld(RABrick, nil, 0, 0.5, 0, 0, 0, 0)
  169. LAW = Weld(LABrick, nil, 0, 0.5, 0, 0, 0, 0)
  170. RLW = Weld(RLBrick, nil, 0, 0.8, 0, 0, 0, 0)
  171. LLW = Weld(LLBrick, nil, 0, 0.8, 0, 0, 0, 0)
  172. HB = Part(Mo, false, false, 1, 0, "White", 0.1, 0.1, 0.1, true)
  173. HBW = Weld(Rarm, HB, 0, 1, 0, 0, 0, 0)
  174. HW = Weld(HB, nil, 0, -1.3, 0, math.pi/2, 0, 0)
  175. TH = Weld(torso, nil, -0.8, 0.4, -0.4, 0, math.pi/2, math.rad(80))
  176. THMain = TH.C1
  177. RAWStand, LAWStand, RLWStand, LLWStand, HWStand = nil
  178. NeckStand = necko * CFrame.Angles(math.rad(17), 0, math.rad(35))
  179. handle = Part(Mo, false, false, 0, 0, GuitarColour, 0.6, 1.5, 1.5, true)
  180. handle.Name = "Handle"
  181. handletip1 = Part(Mo, false, false, 0, 0.2, "Really black", 0.5, 0.5, 0.5, true)
  182. local w1 = Weld(handle, handletip1, 0, 1.12, 0, 0, 0, 0)
  183. w1.C0 = CFrame.Angles(math.rad(-45), 0, 0)
  184. Add.Mesh(handletip1, "http://www.roblox.com/asset/?id=9756362", 0.65, 0.45, 0.65)
  185. handletip2 = Part(Mo, false, false, 0, 0.2, "White", 0.5, 0.5, 0.5, true)
  186. Weld(handletip1, handletip2, 0, 0, 0, 0, math.rad(45), 0)
  187. Add.Mesh(handletip2, "http://www.roblox.com/asset/?id=9756362", 0.65, 0.35, 0.65)
  188. for i = 45, 360+45-90, 90 do
  189. local p = Part(Mo, false, false, 0, 0, GuitarColour, 0.7, 0.9, 0.6, true)
  190. local w = Weld(handle, p, 0, 0, 0, 0, 0, 0)
  191. w.C0 = CFrame.Angles(0, math.pi/2, math.rad(i))
  192. w.C1 = CFrame.new(-1, 0, 0) * CFrame.Angles(0, 0, math.pi/4)
  193. end
  194. for i = 0, 40, 40 do
  195. local p = Part(Mo, false, false, 0, 0, "Really black", 0.2, 0.2, 0.2, true)
  196. Add.Mesh(p, "http://www.roblox.com/asset/?id=1033714", 0.14, 0.12, 0.14)
  197. local w = Weld(handle, p, 0, -0.35, -0.7, 0, 0, math.pi/2)
  198. w.C0 = CFrame.Angles(math.rad(i+130), 0, 0)
  199. local p2 = Part(Mo, false, false, 0, 0, "Really black", 0.2, 0.2, 0.2, true)
  200. Instance.new("CylinderMesh",p2).Scale = Vector3.new(1, 0.7, 1)
  201. Weld(p, p2, 0, -0.04, 0, 0, 0, 0)
  202. end
  203. fretboard = Part(Mo, false, false, 0, 0, "Really black", 0.45, 2.6, 0.6, true)
  204. Weld(handle, fretboard, -0.1, -1.95, 0, math.pi/4, 0, 0)
  205. for i = 0, 2.48, 2.48/10 do
  206. local asd = (1*i)
  207. local p = Part(Mo, false, false, 0, 0, "Really black", 0.2, 0.55, 0.2, true)
  208. Instance.new("CylinderMesh",p).Scale = Vector3.new(0.3, 1, 0.3)
  209. Weld(fretboard, p, -0.21, 0, -1.1+asd, math.pi/2, 0, 0)
  210. end
  211. Strings = {}
  212. for i = -0.24, 0.24, 0.48/6 do
  213. local p = Part(Mo, false, false, 0, 0, "White", 0.2, 3.7, 0.2, true)
  214. Instance.new("CylinderMesh",p).Scale = Vector3.new(0.06, 1, 0.06)
  215. local w = Weld(fretboard, p, -0.25, 0.75, i+0.04, 0, 0, 0)
  216. table.insert(Strings, {p, w})
  217. end
  218. for i = -20, 20, 20 do
  219. local asd = (20+i)/60
  220. local p = Part(Mo, false, false, 0, 0, "White", 0.2, 0.3, 0.6, true)
  221. Instance.new("BlockMesh",p).Scale = Vector3.new(1, 0.5, 1)
  222. local w = Weld(fretboard, p, 0, 0, 0, 0, 0, 0)
  223. w.C0 = CFrame.new(0.11, -1.5-asd, 0)
  224. w.C1 = CFrame.Angles(math.rad(i), 0, 0)
  225. for x = -0.18, 0.18, 0.18 do
  226. local p2 = Part(Mo, false, false, 0, 0, "Really black", 0.2, 0.2, 0.2, true)
  227. Instance.new("CylinderMesh",p2).Scale = Vector3.new(0.5, 0.3, 0.5)
  228. Weld(p, p2, 0, -0.08, x, 0, 0, math.pi/2)
  229. end
  230. end
  231. stringattach = Part(Mo, false, false, 0, 0, "Really black", 0.2, 0.2, 0.8, true)
  232. Instance.new("BlockMesh",stringattach)
  233. Weld(fretboard, stringattach, -0.13, 2.55, 0, 0, 0, 0)
  234. vibra = Part(Mo, false, false, 0, 0, "Really black", 0.2, 0.32, 0.2, true)
  235. Instance.new("SpecialMesh",vibra).Scale = Vector3.new(0.35, 1, 0.35)
  236. VW = Weld(stringattach, vibra, 0, -0.15, 0, 0, 0, 0)
  237. VW.C0 = CFrame.new(0, 0, -0.36) * CFrame.Angles(0, 0, math.rad(-75))
  238. vibra2 = Part(Mo, false, false, 0, 0, "Really black", 0.2, 0.62, 0.2, true)
  239. Instance.new("SpecialMesh",vibra2).Scale = Vector3.new(0.35, 1, 0.35)
  240. vwz = Weld(vibra, vibra2, 0, -0.29, 0, 0, 0, 0)
  241. vwz.C0 = CFrame.new(0, 0.15, 0) * CFrame.Angles(0, 0, math.rad(70))
  242. vibra3 = Part(Mo, false, false, 0, 0, GuitarColour, 0.2, 0.3, 0.2, true)
  243. Add.Sphere(vibra3).Scale = Vector3.new(0.55, 1, 0.55)
  244. Weld(vibra2, vibra3, 0, -0.25, 0, 0, 0, 0)
  245. stringat2 = Part(Mo, false, false, 0, 0, "White", 0.2, 0.2, 0.7, true)
  246. Instance.new("BlockMesh",stringat2).Scale = Vector3.new(1, 0.3, 1)
  247. Weld(stringattach, stringat2, -0.02, 0, 0, 0, 0, 0)
  248. for i = -0.2, 0.21, 0.4/5 do
  249. local p = Part(Mo, false, false, 0, 0, "White", 0.2, 0.2, 0.2, true)
  250. Instance.new("BlockMesh",p).Scale = Vector3.new(1, 0.8, 0.2)
  251. Weld(stringat2, p, -0.01, 0, i, 0, 0, 0)
  252. end
  253. stringattach2 = Part(Mo, false, false, 0, 0, GuitarColour, 0.45, 1.2, 0.62, true)
  254. local wdz = Weld(fretboard, stringattach2, 0, 0, 0, 0, 0, math.rad(8))
  255. wdz.C0 = CFrame.new(0.1, 1.7, 0)
  256. for i = 0, 180, 180 do
  257. local p = Part(Mo, false, false, 0, 0, GuitarColour, 0.45, 1.2, 0.62, true)
  258. Instance.new("SpecialMesh",p).MeshType = "Wedge"
  259. local w = Weld(stringattach2, p, 0, 0, -0.21, math.rad(20), 0, math.pi)
  260. w.C0 = CFrame.new(0, 0.4, 0) * CFrame.Angles(0, math.rad(i), 0)
  261. for x = -0.4, 0.2, 0.3 do
  262. local asd = -0.15 + (i/600)
  263. local p2 = Part(Mo, false, false, 0, 0, "White", 0.2, 0.2, 0.2, true)
  264. local w2 = Weld(p, p2, 0, 0, 0, 0, 0, math.pi/2)
  265. w2.C0 = CFrame.new(asd, x, 0.15)
  266. Instance.new("CylinderMesh",p2)
  267. local p3 = Part(Mo, false, false, 0, 0, "Really black", 0.2, 0.3, 0.2, true)
  268. Instance.new("CylinderMesh",p3).Scale = Vector3.new(0.8, 1, 0.8)
  269. Weld(p2, p3, 0, 0, 0, 0, 0, 0)
  270. end
  271. end
  272. for i = -0.6, 0.61, 1.2 do
  273. local p = Part(Mo, false, false, 0, 0, "Really black", 0.5, 2.8, 0.2, true)
  274. Weld(torso, p, 0, 0, i, 0, 0, math.rad(-40))
  275. local p2 = Part(Mo, false, false, 0, 0, "Really black", 0.5, 0.2, 1.1, true)
  276. Weld(torso, p2, -i*1.4, i*1.75, 0, 0, 0, 0)
  277.  
  278. end
  279. Mo.Parent = char
  280. TH.Part1 = handle
  281. if script.Parent.className ~= "HopperBin" then
  282. h = Instance.new("HopperBin",me.Backpack)
  283. h.Name = Toolname
  284. h.TextureId = ToolIcon
  285. script.Parent = h
  286. end
  287. bin = script.Parent
  288. function detach(bool)
  289. LLW.C0 = CFrame.new(0, 0, 0)
  290. RLW.C0 = CFrame.new(0, 0, 0)
  291. LAW.C0 = CFrame.new(0,0,0)
  292. RAW.C0 = CFrame.new(0, 0, 0)
  293. if bool then
  294. LLW.Part1 = nil
  295. RLW.Part1 = nil
  296. RAW.Part1 = nil
  297. LAW.Part1 = nil
  298. end
  299. end
  300. function attach()
  301. RAW.Part1 = Rarm
  302. LAW.Part1 = Larm
  303. RLW.Part1 = Rleg
  304. LLW.Part1 = Lleg
  305. end
  306. function normal()
  307. neck.C0 = NeckStand
  308. RAW.C0 = RAWStand
  309. LAW.C0 = LAWStand
  310. RLW.C0 = RLWStand
  311. LLW.C0 = LLWStand
  312. RAW.C1 = CFrame.new(0, 0.5, 0)
  313. LAW.C1 = CFrame.new(0, 0.5, 0)
  314. RLW.C1 = CFrame.new(0, 0.8, 0)
  315. LLW.C1 = CFrame.new(0, 0.8, 0)
  316. HW.C0 = HWStand
  317. end
  318. function selectanim()
  319. RAW.Part1 = Rarm
  320. for i = 0.09, 1, 0.09 do
  321. TH.C0 = CFrame.Angles(0, math.rad(90*i), 0)
  322. TH.C1 = THMain * CFrame.Angles(0, 0, math.rad(-30*i)) * CFrame.new(0, 0.3*i, -0.1*i)
  323. RAW.C0 = CFrame.Angles(math.rad(110*i), 0, math.rad(10*i)) * CFrame.new(0, 0, -0.3*i)
  324. neck.C0 = necko * CFrame.Angles(math.rad(5*i), 0, math.rad(-35*i))
  325. wait()
  326. end
  327. LAW.Part1 = Larm
  328. for i = 0.1, 1, 0.1 do
  329. TH.C0 = CFrame.Angles(0, math.rad(90+90*i), 0)
  330. TH.C1 = THMain * CFrame.Angles(math.rad(15*i), 0, math.rad(-30-30*i)) * CFrame.new(0, 0.3+0.2*i, -0.1)
  331. RAW.C0 = CFrame.Angles(math.rad(110-65*i), 0, math.rad(10-30*i)) * CFrame.new(0, -0.5*i, -0.3-0.2*i)
  332. LAW.C0 = CFrame.Angles(math.rad(75*i), math.rad(-15*i), math.rad(-10*i)) * CFrame.new(0, -0.2*i, 0)
  333. neck.C0 = necko * CFrame.Angles(math.rad(5+12*i), 0, math.rad(-35+70*i))
  334. wait()
  335. end
  336. if RAWStand == nil then
  337. RAWStand = RAW.C0
  338. LAWStand = LAW.C0
  339. RLWStand = RLW.C0
  340. LLWStand = LLW.C0
  341. HWStand = HW.C0
  342. end
  343. normal()
  344. end
  345. function deselanim()
  346. for i = 0.9, 0, -0.1 do
  347. TH.C0 = CFrame.Angles(0, math.rad(90+90*i), 0)
  348. TH.C1 = THMain * CFrame.Angles(math.rad(15*i), 0, math.rad(-30-30*i)) * CFrame.new(0, 0.3+0.2*i, -0.1)
  349. RAW.C0 = CFrame.Angles(math.rad(110-65*i), 0, math.rad(10-30*i)) * CFrame.new(0, -0.5*i, -0.3-0.2*i)
  350. LAW.C0 = CFrame.Angles(math.rad(75*i), math.rad(-15*i), math.rad(-10*i)) * CFrame.new(0, -0.2*i, 0)
  351. neck.C0 = necko * CFrame.Angles(math.rad(5+12*i), 0, math.rad(-35+70*i))
  352. wait()
  353. end
  354. LAW.Part1 = nil
  355. for i = 0.91, 0, -0.09 do
  356. TH.C0 = CFrame.Angles(0, math.rad(90*i), 0)
  357. TH.C1 = THMain * CFrame.Angles(0, 0, math.rad(-30*i)) * CFrame.new(0, 0.3*i, -0.1*i)
  358. RAW.C0 = CFrame.Angles(math.rad(110*i), 0, math.rad(10*i)) * CFrame.new(0, 0, -0.3*i)
  359. neck.C0 = necko * CFrame.Angles(math.rad(5*i), 0, math.rad(-35*i))
  360. wait()
  361. end
  362. neck.C0 = necko
  363. detach(true)
  364. end
  365. keys = {"r", "t", "y", "u", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m"}
  366. function PlayString(pitch, vol)
  367. LAW.C0 = LAWStand * CFrame.new(pitch/7, 0, 0) * CFrame.Angles(0, 0, math.rad(pitch*18))
  368. neck.C0 = NeckStand * CFrame.Angles(0, 0, math.rad(-pitch*13))
  369. for i = 0, 1, 0.5 do
  370. RAW.C0 = RAWStand * CFrame.Angles(math.rad(-5*i), 0, math.rad(-15*i)) * CFrame.new(0, 0.3*i, 0)
  371. wait()
  372. end
  373. GSound.Pitch=pitch
  374. GSound.Volume=vol
  375. GSound:Play()
  376. for i = 0, 1, 0.33 do
  377. RAW.C0 = RAWStand * CFrame.Angles(math.rad(-5-10*i), 0, math.rad(-15+35*i)) * CFrame.new(0, 0.3-0.8*i, 0)
  378. wait()
  379. end
  380. local lol = math.floor(pitch*2.5)
  381. if lol < 1 then lol = 1 elseif lol > #keys then lol = #keys end
  382. coroutine.resume(coroutine.create(function()
  383. local vollol = vol*40
  384. for i = 1, math.random(vollol/1.8, vollol) do
  385. Strings[lol][2].C0 = CFrame.new(0, 0, math.random(-vollol, vollol)/1000)
  386. wait()
  387. end
  388. Strings[lol][2].C0 = CFrame.new()
  389. end))
  390. for i = 0, 1, 0.25 do
  391. RAW.C0 = RAWStand * CFrame.Angles(math.rad(-5-10+15*i), 0, math.rad(20-20*i)) * CFrame.new(0, 0.3-0.8+0.5*i, 0)
  392. wait()
  393. end
  394. RAW.C0 = RAWStand
  395. end
  396. function select(mouse)
  397. selectanim()
  398. selected = true
  399. mouse.KeyDown:connect(function(key)
  400. key = key:lower()
  401. for i, v in pairs(keys) do
  402. if key == v then
  403. local pitch = 0.3 + (i/7.5)
  404. PlayString(pitch, volume)
  405. end
  406. end
  407. end)
  408. end
  409. function deselect(mouse)
  410. selected = false
  411. deselanim()
  412. end
  413. bin.Selected:connect(select)
  414. bin.Deselected:connect(deselect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement