Advertisement
MysteriousL

Art test

Jul 25th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.70 KB | None | 0 0
  1. Player = game.Players.megatron2006 -- PLAYERNAME HERE
  2. Name = "Artillery Beacon"
  3. selected = false
  4. Button1Down = false
  5. thrown = false
  6.  
  7.  
  8. function makeParts(format)
  9. local beacon = Instance.new("Model")
  10. beacon.Name = Name
  11. beacon.Parent = Player.Character
  12. local pm = Instance.new("Part")
  13. pm.Name = "Handle"
  14. pm.FormFactor = "Custom"
  15. pm.Size = Vector3.new(1, 1, 1)
  16. pm.BrickColor = BrickColor.new("Really black")
  17. pm.Locked = true
  18. pm.TopSurface = 0
  19. pm.BottomSurface = 0
  20. pm.Parent = beacon
  21. local m = Instance.new("SpecialMesh")
  22. m.MeshType = "Brick"
  23. m.Scale = Vector3.new(0.5, 1.25, 0.2)
  24. m.Parent = pm
  25. local w = Instance.new("Weld")
  26. w.Part0 = pm
  27. if format == "hand" then
  28. w.Part1 = Player.Character:FindFirstChild("Right Arm")
  29. w.C0 = CFrame.new(-1.2, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, math.rad(90))
  30. w.C1 = CFrame.new()
  31. elseif format == "holster" then
  32. w.Part1 = Player.Character:FindFirstChild("Torso")
  33. w.C0 = CFrame.new(0.7, 0.25, 0.6)
  34. w.C1 = CFrame.new()
  35. beacon.Name = Name.. " (Holstered)"
  36. end
  37. w.Parent = pm
  38. local s = Instance.new("Sound")
  39. s.Name = "Explode"
  40. s.SoundId = "http://www.roblox.com/Asset/?id=2101148"
  41. s.Volume = 1
  42. s.Pitch = 1
  43. s.Looped = false
  44. s.Parent = pm
  45. local s = Instance.new("Sound")
  46. s.Name = "Beep"
  47. s.SoundId = "http://www.roblox.com/Asset/?id=15666462"
  48. s.Volume = 1
  49. s.Pitch = 0.75
  50. s.Looped = true
  51. s.Parent = pm
  52. local p = Instance.new("Part")
  53. p.Name = "Antenna"
  54. p.FormFactor = "Custom"
  55. p.Size = Vector3.new(1, 1, 1)
  56. p.BrickColor = BrickColor.new("Dark stone grey")
  57. p.Transparency = 0
  58. p.Locked = true
  59. p.TopSurface = 0
  60. p.BottomSurface = 0
  61. p.Parent = beacon
  62. local m = Instance.new("CylinderMesh")
  63. m.Scale = Vector3.new(0.1, 0.5, 0.1)
  64. m.Parent = p
  65. local w = Instance.new("Weld")
  66. w.Part0 = p
  67. w.Part1 = pm
  68. w.C0 = CFrame.new(0.1, -0.85, 0)
  69. w.C1 = CFrame.new()
  70. w.Parent = p
  71. local p = Instance.new("Part")
  72. p.Name = "Light"
  73. p.FormFactor = "Custom"
  74. p.Size = Vector3.new(1, 1, 1)
  75. p.BrickColor = BrickColor.new("Bright green")
  76. p.Transparency = 1
  77. p.Locked = true
  78. p.TopSurface = 0
  79. p.BottomSurface = 0
  80. p.Parent = beacon
  81. local m = Instance.new("SpecialMesh")
  82. m.MeshType = "Sphere"
  83. m.Scale = Vector3.new(0.1, 0.1, 0.1)
  84. m.Parent = p
  85. local w = Instance.new("Weld")
  86. w.Part0 = p
  87. w.Part1 = pm
  88. w.C0 = CFrame.new(-0.175, -0.64, 0)
  89. w.C1 = CFrame.new()
  90. w.Parent = p
  91. end
  92.  
  93.  
  94. function removeParts(format)
  95. if format == "hand" then
  96. if Player.Character:FindFirstChild(Name) ~= nil then
  97. Player.Character[Name]:Remove()
  98. end
  99. elseif format == "holster" then
  100. if Player.Character:FindFirstChild(Name.. " (Holstered)") ~= nil then
  101. Player.Character[Name.. " (Holstered)"]:Remove()
  102. end
  103. end
  104. end
  105.  
  106.  
  107. function SetAngle(Joint, Angle, Character)
  108. if Character == nil then return false end
  109. local Joints = {
  110. Character.Torso:FindFirstChild("Right Shoulder 2"),
  111. Character.Torso:FindFirstChild("Left Shoulder 2"),
  112. Character.Torso:FindFirstChild("Right Hip 2"),
  113. Character.Torso:FindFirstChild("Left Hip 2")
  114. }
  115. if Joints[Joint] == nil then return false end
  116. if Joint == 1 or Joint == 3 then
  117. Joints[Joint].DesiredAngle = Angle
  118. end
  119. if Joint == 2 or Joint == 4 then
  120. Joints[Joint].DesiredAngle = -Angle
  121. end
  122. end
  123.  
  124.  
  125. function ForceAngle(Joint, Angle, Character)
  126. if Character == nil then return false end
  127. local Joints = {
  128. Character.Torso:FindFirstChild("Right Shoulder 2"),
  129. Character.Torso:FindFirstChild("Left Shoulder 2"),
  130. Character.Torso:FindFirstChild("Right Hip 2"),
  131. Character.Torso:FindFirstChild("Left Hip 2")
  132. }
  133. if Joints[Joint] == nil then return false end
  134. if Joint == 1 or Joint == 3 then
  135. Joints[Joint].DesiredAngle = Angle
  136. Joints[Joint].CurrentAngle = Angle
  137. end
  138. if Joint == 2 or Joint == 4 then
  139. Joints[Joint].DesiredAngle = -Angle
  140. Joints[Joint].CurrentAngle = -Angle
  141. end
  142. end
  143.  
  144.  
  145. function SetSpeed(Joint, Speed, Character)
  146. if Character == nil then return false end
  147. local Joints = {
  148. Character.Torso:FindFirstChild("Right Shoulder 2"),
  149. Character.Torso:FindFirstChild("Left Shoulder 2"),
  150. Character.Torso:FindFirstChild("Right Hip 2"),
  151. Character.Torso:FindFirstChild("Left Hip 2")
  152. }
  153. if Joints[Joint] == nil then return false end
  154. Joints[Joint].MaxVelocity = Speed
  155. end
  156.  
  157.  
  158. function DisableLimb(Limb, Character)
  159. if Character == nil then return false end
  160. if Character:FindFirstChild("Torso") == nil then return false end
  161. local Joints = {
  162. Character.Torso:FindFirstChild("Right Shoulder"),
  163. Character.Torso:FindFirstChild("Left Shoulder"),
  164. Character.Torso:FindFirstChild("Right Hip"),
  165. Character.Torso:FindFirstChild("Left Hip")
  166. }
  167. local Limbs = {
  168. Character:FindFirstChild("Right Arm"),
  169. Character:FindFirstChild("Left Arm"),
  170. Character:FindFirstChild("Right Leg"),
  171. Character:FindFirstChild("Left Leg")
  172. }
  173. if Joints[Limb] == nil then return false end
  174. if Limbs[Limb] == nil then return false end
  175. local Joint = Instance.new("Motor")
  176. Joint.Parent = Character.Torso
  177. Joint.Part0 = Character.Torso
  178. Joint.Part1 = Limbs[Limb]
  179. if Limb == 1 then
  180. Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  181. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  182. Joint.Name = "Right Shoulder 2"
  183. elseif Limb == 2 then
  184. Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  185. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  186. Joint.Name = "Left Shoulder 2"
  187. elseif Limb == 3 then
  188. Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  189. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  190. Joint.Name = "Right Hip 2"
  191. elseif Limb == 4 then
  192. Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  193. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  194. Joint.Name = "Left Hip 2"
  195. end
  196. Joint.MaxVelocity = Joints[Limb].MaxVelocity
  197. Joint.CurrentAngle = Joints[Limb].CurrentAngle
  198. Joint.DesiredAngle = Joints[Limb].DesiredAngle
  199. Joints[Limb]:Remove()
  200. end
  201.  
  202.  
  203. function ResetLimbCFrame(Limb, Character)
  204. if Character == nil then return false end
  205. if Character.Parent == nil then return false end
  206. if Character:FindFirstChild("Torso") == nil then return false end
  207. local Joints = {
  208. Character.Torso:FindFirstChild("Right Shoulder 2"),
  209. Character.Torso:FindFirstChild("Left Shoulder 2"),
  210. Character.Torso:FindFirstChild("Right Hip 2"),
  211. Character.Torso:FindFirstChild("Left Hip 2")
  212. }
  213. local Limbs = {
  214. Character:FindFirstChild("Right Arm"),
  215. Character:FindFirstChild("Left Arm"),
  216. Character:FindFirstChild("Right Leg"),
  217. Character:FindFirstChild("Left Leg")
  218. }
  219. if Joints[Limb] == nil then return false end
  220. if Limbs[Limb] == nil then return false end
  221. if Limb == 1 then
  222. Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  223. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  224. elseif Limb == 2 then
  225. Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  226. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  227. elseif Limb == 3 then
  228. Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  229. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  230. elseif Limb == 4 then
  231. Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  232. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  233. end
  234. end
  235.  
  236.  
  237. function EnableLimb(Limb, Character)
  238. if Character == nil then return false end
  239. if Character:FindFirstChild("Torso") == nil then return false end
  240. local Joints = {
  241. Character.Torso:FindFirstChild("Right Shoulder 2"),
  242. Character.Torso:FindFirstChild("Left Shoulder 2"),
  243. Character.Torso:FindFirstChild("Right Hip 2"),
  244. Character.Torso:FindFirstChild("Left Hip 2")
  245. }
  246. local Limbs = {
  247. Character:FindFirstChild("Right Arm"),
  248. Character:FindFirstChild("Left Arm"),
  249. Character:FindFirstChild("Right Leg"),
  250. Character:FindFirstChild("Left Leg")
  251. }
  252. if Joints[Limb] == nil then return false end
  253. if Limbs[Limb] == nil then return false end
  254. if Limb == 1 then
  255. Joints[Limb].Name = "Right Shoulder"
  256. elseif Limb == 2 then
  257. Joints[Limb].Name = "Left Shoulder"
  258. elseif Limb == 3 then
  259. Joints[Limb].Name = "Right Hip"
  260. elseif Limb == 4 then
  261. Joints[Limb].Name = "Left Hip"
  262. end
  263. local Animate = Character:FindFirstChild("Animate")
  264. if Animate == nil then return false end
  265. Animate = Animate:Clone()
  266. Character.Animate:Remove()
  267. Animate.Parent = Character
  268. end
  269.  
  270.  
  271. function Weld(x, y)
  272. local weld = Instance.new("Weld")
  273. weld.Part0 = x
  274. weld.Part1 = y
  275. local CJ = CFrame.new(x.Position)
  276. local C0 = x.CFrame:inverse() * CJ
  277. local C1 = y.CFrame:inverse() * CJ
  278. weld.C0 = C0
  279. weld.C1 = C1
  280. weld.Parent = x
  281. end
  282.  
  283.  
  284. function tagHumanoid(humanoid)
  285. local tag = Instance.new("ObjectValue")
  286. tag.Name = "creator"
  287. tag.Value = Player
  288. tag.Parent = humanoid
  289. local tag = Instance.new("StringValue")
  290. tag.Name = "creatorType1"
  291. tag.Value = Name
  292. tag.Parent = humanoid
  293. local tag = Instance.new("StringValue")
  294. tag.Name = "creatorType2"
  295. tag.Value = "blown to pieces"
  296. tag.Parent = humanoid
  297. end
  298.  
  299.  
  300. function untagHumanoid(humanoid)
  301. if humanoid ~= nil then
  302. local tag = humanoid:FindFirstChild("creator")
  303. if tag ~= nil then
  304. tag:Remove()
  305. end
  306. local tag = humanoid:FindFirstChild("creatorType1")
  307. if tag ~= nil then
  308. tag:Remove()
  309. end
  310. local tag = humanoid:FindFirstChild("creatorType2")
  311. if tag ~= nil then
  312. tag:Remove()
  313. end
  314. end
  315. end
  316.  
  317.  
  318. function fire(v)
  319. if Player.Character:FindFirstChild(Name) == nil then makeParts("hand") end
  320. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  321. if Player.Character[Name].Handle:FindFirstChild("Weld") ~= nil then Player.Character[Name].Handle.Weld:Remove() end
  322. local bodyVelocity = Instance.new("BodyVelocity")
  323. bodyVelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  324. bodyVelocity.velocity = v * 75
  325. bodyVelocity.Parent = Player.Character[Name].Handle
  326. wait(0.1)
  327. bodyVelocity:Remove()
  328. end
  329.  
  330.  
  331. function onButton1Down(mouse)
  332. if selected == false then return end
  333. if Player.Character:FindFirstChild(Name) ~= nil and Button1Down ~= true and thrown ~= true then
  334. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  335. if Player.Character[Name]:FindFirstChild("Antenna") == nil then return end
  336. if Player.Character[Name]:FindFirstChild("Light") == nil then return end
  337. Button1Down = true
  338. Player.Character[Name].Light.Transparency = 0.4
  339. coroutine.resume(coroutine.create(function(target)
  340. local pos1 = target.Position
  341. local pos2 = pos1
  342. while true do
  343. if target == nil then return end
  344. if target.Parent == nil then return end
  345. pos2 = pos1
  346. pos1 = target.Position
  347. local trail = Instance.new("Part")
  348. trail.BrickColor = target.BrickColor
  349. trail.TopSurface = 0
  350. trail.BottomSurface = 0
  351. trail.FormFactor = target.FormFactor
  352. trail.Size = Vector3.new(1, 1, 1)
  353. trail.Reflectance = 0
  354. trail.Transparency = 0.3
  355. trail.Anchored = true
  356. trail.CanCollide = false
  357. trail.CFrame = CFrame.new((pos1 + pos2) / 2, pos2)
  358. trail.Parent = workspace
  359. local mesh = Instance.new("SpecialMesh")
  360. mesh.MeshType = "Brick"
  361. mesh.Scale = Vector3.new(0.2, 0.2, (pos2 - pos1).magnitude)
  362. mesh.Parent = trail
  363. coroutine.resume(coroutine.create(function(part) for i = 3, 10, 1 do part.Transparency = i / 10 wait(0.1) end part:Remove() end), trail)
  364. wait()
  365. end
  366. end), Player.Character[Name].Light)
  367. wait(0.5)
  368. Player.Character[Name].Handle.Beep:Play()
  369. Player.Character[Name].Light.BrickColor = BrickColor.new("Bright orange")
  370. coroutine.resume(coroutine.create(function()
  371. wait(3)
  372. if Player.Character:FindFirstChild(Name) ~= nil then
  373. if Player.Character[Name]:FindFirstChild("Light") ~= nil then Player.Character[Name].Light.BrickColor = BrickColor.new("Really red") end
  374. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then Player.Character[Name].Handle.Beep.Pitch = 1.25 end
  375. local position = Player.Character[Name].Handle.Position
  376. local s = Player.Character[Name].Handle.Explode:Clone()
  377. Tool:Remove()
  378. coroutine.resume(coroutine.create(function()
  379. local weld1 = Player.Character[Name].Light:FindFirstChild("Weld")
  380. local weld2 = Player.Character[Name].Antenna:FindFirstChild("Weld")
  381. if weld1 == nil then return end
  382. if weld2 == nil then return end
  383. local weld1c = weld1:Clone()
  384. local weld2c = weld2:Clone()
  385. while true do
  386. if Player.Character ~= nil then
  387. if Player.Character:FindFirstChild(Name) ~= nil then
  388. if weld1.Parent == nil then
  389. if Player.Character[Name]:FindFirstChild("Light") ~= nil then
  390. weld1c:Clone().Parent = Player.Character[Name].Light
  391. Player.Character[Name]:MakeJoints()
  392. end
  393. end
  394. if weld2.Parent == nil then
  395. if Player.Character[Name]:FindFirstChild("Handle") ~= nil then
  396. weld2c:Clone().Parent = Player.Character[Name].Antenna
  397. Player.Character[Name]:MakeJoints()
  398. end
  399. end
  400. end
  401. end
  402. wait()
  403. end
  404. end))
  405. for i = 0, math.random(30, 50) do
  406. if Player.Character:FindFirstChild("Humanoid") ~= nil then
  407. if Player.Character.Humanoid.Health <= 0 then break end
  408. local shell = Instance.new("Part")
  409. shell.Name = "Artillery Shell"
  410. shell.Anchored = true
  411. shell.BrickColor = BrickColor.new("Medium stone grey")
  412. shell.FormFactor = "Custom"
  413. shell.Size = Vector3.new(2, 5, 2)
  414. shell.TopSurface = 0
  415. shell.BottomSurface = 0
  416. shell.Parent = workspace
  417. coroutine.resume(coroutine.create(function(part)
  418. local offset = Vector3.new(math.random(-50, 50), math.random(-10, 10), math.random(-50, 50))
  419. for i = 1000, 0, -25 do
  420. part.CFrame = CFrame.new((position + offset) + Vector3.new(0, i, 0))
  421. wait()
  422. end
  423. local e = Instance.new("Explosion")
  424. e.Position = part.Position
  425. e.BlastPressure = 500000
  426. e.BlastRadius = 25
  427. e.Parent = workspace
  428. e.Hit:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then tagHumanoid(hit.Parent.Humanoid) delay(1, function() untagHumanoid(hit.Parent.Humanoid) end) end end)
  429. local s2 = s:Clone()
  430. s2.Pitch = math.random(70, 90) / 100
  431. s2.Parent = workspace
  432. s2:Play()
  433. part:Remove()
  434. end), shell)
  435. end
  436. wait(math.random(1, 5) / 10)
  437. end
  438. if Player.Character:FindFirstChild(Name) ~= nil then if Player.Character[Name]:FindFirstChild("Handle") ~= nil then Player.Character[Name].Handle.Beep:Stop() end end
  439. end
  440. removeParts("hand")
  441. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  442. Player.Character.WeaponActivated:Remove()
  443. end
  444. thrown = false
  445. Button1Down = false
  446. selected = true
  447. onDeselected(mouse)
  448. removeParts("holster")
  449. script:Remove()
  450. end))
  451. end
  452. end
  453.  
  454.  
  455. function onButton1Up(mouse)
  456. if selected == false then return end
  457. if Button1Down == true and thrown ~= true then
  458. thrown = true
  459. SetSpeed(1, 0.75, Player.Character)
  460. SetAngle(1, 0, Player.Character)
  461. EnableLimb(1, Player.Character)
  462. fire((mouse.Hit.p - Player.Character[Name].Handle.Position).unit)
  463. end
  464. Button1Down = false
  465. end
  466.  
  467.  
  468. function onKeyDown(key, mouse)
  469. if selected == false then return end
  470. key = key:lower()
  471. if key == "q" and Button1Down == false and thrown ~= true then
  472. if mouse.Target == nil then return end
  473. if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
  474. onDeselected(mouse)
  475. removeParts("holster")
  476. script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
  477. end
  478. end
  479. end
  480.  
  481.  
  482. function onSelected(mouse)
  483. if selected == true then return end
  484. selected = true
  485. while Player.Character:FindFirstChild("WeaponActivated") ~= nil or thrown == true do
  486. if Player.Character.WeaponActivated.Value == nil then break end
  487. if Player.Character.WeaponActivated.Value.Parent == nil then break end
  488. wait()
  489. end
  490. removeParts("holster")
  491. makeParts("hand")
  492. local weapon = Instance.new("ObjectValue")
  493. weapon.Name = "WeaponActivated"
  494. weapon.Value = script.Parent
  495. weapon.Parent = Player.Character
  496. DisableLimb(1, Player.Character)
  497. SetAngle(1, math.rad(200), Player.Character)
  498. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  499. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  500. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  501. end
  502.  
  503.  
  504. function onDeselected(mouse)
  505. if selected == false then return end
  506. selected = false
  507. while Button1Down == true or thrown == true do
  508. wait()
  509. end
  510. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  511. if Player.Character.WeaponActivated.Value == script.Parent then
  512. Player.Character.WeaponActivated:Remove()
  513. end
  514. end
  515. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  516. if Player.Character.WeaponActivated.Value == nil then break end
  517. if pcall(function() if Player.Character.WeaponActivated.Value.Parent == nil then return true end end) then break end
  518. wait()
  519. end
  520. removeParts("hand")
  521. makeParts("holster")
  522. SetAngle(1, 0, Player.Character)
  523. EnableLimb(1, Player.Character)
  524. end
  525.  
  526.  
  527. if script.Parent.ClassName ~= "HopperBin" then
  528. Tool = Instance.new("HopperBin")
  529. Tool.Name = Name
  530. Tool.Parent = Player.Backpack
  531. script.Name = "Main"
  532. script.Parent = Tool
  533. makeParts("holster")
  534. Tool.Selected:connect(onSelected)
  535. Tool.Deselected:connect(onDeselected)
  536. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement