Advertisement
Tr3VeR

Striker

Mar 25th, 2017
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.81 KB | None | 0 0
  1. local player = game:GetService("Players").LocalPlayer
  2.  
  3. local bin = Instance.new("HopperBin", player.Backpack)
  4.  
  5. bin.Name = "Striker unit"
  6.  
  7. local camera = game:GetService("Workspace").CurrentCamera
  8. local character = player.Character
  9.  
  10. local torso = character:FindFirstChild("Torso")
  11. local humanoid = character:FindFirstChild("Humanoid")
  12. local neck = torso:FindFirstChild("Neck")
  13.  
  14. local rightLeg = character:FindFirstChild("Right Leg")
  15. local leftLeg = character:FindFirstChild("Left Leg")
  16.  
  17. local rightHip = torso:FindFirstChild("Right Hip")
  18. local leftHip = torso:FindFirstChild("Left Hip")
  19.  
  20. local neckAngle = neck.C1
  21. local rightHipAngle = rightHip.C1
  22. local leftHipAngle = leftHip.C1
  23.  
  24. local leftWeld = Instance.new("Weld")
  25. local rightWeld = Instance.new("Weld")
  26.  
  27. local velocity = Instance.new("BodyVelocity")
  28. local gyro = Instance.new("BodyGyro")
  29. local pos = Instance.new("BodyPosition")
  30.  
  31. local parts = {"StrikerOne", "StrikerTwo", "JointOne", "JointTwo", "PropellerOne", "PropellerTwo"}
  32. local welds = {"SWelderOne", "SWelderTwo", "JWelderOne", "JWelderTwo", "PWelderOne", "PWelderTwo"}
  33.  
  34. local strikerColor = "Really black"
  35. local propellerColor = "White"
  36. local jointColor = "Bright blue"
  37.  
  38. local mainModel = Instance.new("Model")
  39. local cframePart = Instance.new("Part")
  40.  
  41. local toolSelected = false
  42. local runNext = false
  43. local strikerLoaded = false
  44. local connected = false
  45. local turn = false
  46. local forward = false
  47. local backward = false
  48. local onleft = false
  49. local onright = false
  50. local onup = false
  51. local ondown = false
  52.  
  53.  
  54. local gyroAngleX = 0
  55. local desiredGyroAngleX = 0
  56. local gyroAngleY = 0
  57. local desiredGyroAngleY = 0
  58. local gyroAngleZ = 0
  59. local desiredGyroAngleZ = 0
  60. local angleSetSpeed = 5
  61. local rotationIndice = 0
  62. local maxRotation = 70
  63. local motorSpeed = 0
  64. local desiredSpeed = 0
  65. local xPartPos = 0
  66. local desiredXPartPos = 0
  67. local yPartPos = 0
  68. local desiredYPartPos = 0
  69.  
  70. function Striker(delay)
  71.  
  72. wait(delay)
  73.  
  74. mainModel.Name = "Striker"
  75. mainModel.Archivable = false
  76. mainModel.Parent = character
  77.  
  78. for index, name in pairs(parts) do
  79.  
  80. getfenv()[name] = Instance.new("Part")
  81. getfenv()[name].Name = name
  82. getfenv()[name].Anchored = true
  83. getfenv()[name].Locked = true
  84. getfenv()[name].CanCollide = false
  85. getfenv()[name].Transparency = 1
  86. getfenv()[name].CFrame = CFrame.new(0, math.huge, 0)
  87. getfenv()[name].FormFactor = Enum.FormFactor.Custom
  88. getfenv()[name].BottomSurface = Enum.SurfaceType.Smooth
  89. getfenv()[name].TopSurface = Enum.SurfaceType.Smooth
  90.  
  91. if index <= 2 then
  92.  
  93. getfenv()[name].BrickColor = BrickColor.new(strikerColor)
  94. getfenv()[name].Size = Vector3.new(1.1, 1.5, 1.1)
  95.  
  96. elseif index == 3 or index == 4 then
  97.  
  98. getfenv()[name].BrickColor = BrickColor.new(jointColor)
  99. getfenv()[name].Size = Vector3.new(0.25, 0.25, 0.25)
  100.  
  101. elseif index >= 5 then
  102.  
  103. getfenv()[name].BrickColor = BrickColor.new(propellerColor)
  104. getfenv()[name].Size = Vector3.new(1.55, 0.2, 0.2)
  105.  
  106. end
  107.  
  108. getfenv()[name].Parent = mainModel
  109.  
  110. coroutine.resume(coroutine.create(function()
  111.  
  112. for i = getfenv()[name].Transparency, 0, -0.1 do
  113.  
  114. if toolSelected then wait() getfenv()[name].Transparency = i end
  115.  
  116. end
  117.  
  118. end))
  119.  
  120. end
  121.  
  122. for index, name in pairs(welds) do
  123.  
  124. getfenv()[name] = Instance.new("Weld")
  125. getfenv()[name].Parent = mainModel
  126. getfenv()[name].Name = name
  127.  
  128. if index == 1 then
  129.  
  130. getfenv()[name].Part0 = leftLeg
  131. StrikerOne.Anchored = false
  132. getfenv()[name].Part1 = StrikerOne
  133. getfenv()[name].C1 = CFrame.new(0, 0.35, 0)
  134.  
  135. elseif index == 2 then
  136.  
  137. getfenv()[name].Part0 = rightLeg
  138. StrikerTwo.Anchored = false
  139. getfenv()[name].Part1 = StrikerTwo
  140. getfenv()[name].C1 = CFrame.new(0, 0.35, 0)
  141.  
  142. elseif index == 3 then
  143.  
  144. getfenv()[name].Part0 = StrikerOne
  145. JointOne.Anchored = false
  146. getfenv()[name].Part1 = JointOne
  147. getfenv()[name].C1 = CFrame.new(0, 0.775, 0)
  148. JointOne.CanCollide = true
  149.  
  150. elseif index == 4 then
  151.  
  152. getfenv()[name].Part0 = StrikerTwo
  153. JointTwo.Anchored = false
  154. getfenv()[name].Part1 = JointTwo
  155. getfenv()[name].C1 = CFrame.new(0, 0.775, 0)
  156. JointTwo.CanCollide = true
  157.  
  158. elseif index == 5 then
  159.  
  160. getfenv()[name].Part0 = JointOne
  161. PropellerOne.Anchored = false
  162. getfenv()[name].Part1 = PropellerOne
  163.  
  164. elseif index == 6 then
  165.  
  166. getfenv()[name].Part0 = JointTwo
  167. PropellerTwo.Anchored = false
  168. getfenv()[name].Part1 = PropellerTwo
  169.  
  170. end
  171.  
  172. end
  173.  
  174. wait(0.1)
  175.  
  176. strikerLoaded = true
  177.  
  178. end
  179.  
  180. function SetAngles(cfr, x, y, z) print("Settings")
  181.  
  182. local x2, y2, z2 = cfr.C1:toEulerAnglesXYZ()
  183.  
  184. x = math.rad(x)
  185. y = math.rad(y)
  186. z = math.rad(z)
  187.  
  188. x2 = math.rad(x2)
  189. y2 = math.rad(y2)
  190. z2 = math.rad(z2)
  191.  
  192. coroutine.resume(coroutine.create(function() local v1 local v2
  193.  
  194. if x2 < x then v1, v2 = x2, x else v1, v2 = x, x2 end
  195.  
  196. for i = v1, v2, (v2 - v1) / angleSetSpeed do wait()
  197.  
  198. cfr.C1 = unitCfr * CFrame.fromEulerAnglesXYZ(i/v2, 0, 0)
  199.  
  200. end
  201.  
  202. end))
  203.  
  204. coroutine.resume(coroutine.create(function() local v3 local v4
  205.  
  206. if y2 < y then v3, v4 = y2, y else v3, v4 = y, x2 end
  207.  
  208. for i = v3, v4, (v2 - v1) / angleSetSpeed do wait()
  209.  
  210. cfr.C1 = unitCfr * CFrame.fromEulerAnglesXYZ(0, i/v4, 0)
  211.  
  212. end
  213.  
  214. end))
  215.  
  216. coroutine.resume(coroutine.create(function() local v5 local v6
  217.  
  218. if z2 < z then v5, v6 = z2, z else v5, v6 = z, z2 end
  219.  
  220. for i = v5, v6, (v5 - v6) / angleSetSpeed do wait()
  221.  
  222. cfr.C1 = unitCfr * CFrame.fromEulerAnglesXYZ(0, 0, i/v6)
  223.  
  224. end
  225.  
  226. end))
  227.  
  228. end
  229.  
  230. function Connection(mouse)
  231.  
  232. toolSelected = true
  233.  
  234. coroutine.resume(coroutine.create(function() repeat wait()
  235.  
  236. if toolSelected then
  237.  
  238. if leftHip ~= nil then
  239.  
  240. leftHip.DesiredAngle = 0
  241. leftHip.CurrentAngle = 0
  242.  
  243. end
  244.  
  245. if rightHip ~= nil then
  246.  
  247. rightHip.DesiredAngle = 0
  248. rightHip.CurrentAngle = 0
  249.  
  250. end
  251.  
  252. runNext = true
  253.  
  254. else break end
  255.  
  256. until false return false end))
  257.  
  258. repeat wait() until runNext
  259.  
  260. humanoid.PlatformStand = true
  261.  
  262. torso.Anchored = true wait()
  263. torso.Velocity = Vector3.new(0, 0, 0)
  264. torso.RotVelocity = Vector3.new(0, 0, 0)
  265.  
  266. leftHipAngle = leftHip.C1
  267. rightHipAngle = rightHip.C1
  268.  
  269. pos.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  270. pos.Parent = torso
  271. pos.position = torso.CFrame.p
  272.  
  273. torso.Anchored = false
  274.  
  275. coroutine.resume(coroutine.create(Striker),0.2)
  276.  
  277. for i = 1, 20, 1 do wait()
  278.  
  279. if toolSelected then
  280.  
  281. pos.position = pos.position + Vector3.new(0, 0.2, 0)
  282. torso.CFrame = torso.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(18), 0)
  283. humanoid.PlatformStand = true
  284.  
  285. leftHip.C1 = leftHip.C1 * CFrame.new(0, -0.01, 0) * CFrame.fromEulerAnglesXYZ(math.rad(0.5), -math.rad(0.5), -math.rad(0.5))
  286. rightHip.C1 = rightHip.C1 * CFrame.new(0, -0.01, 0) * CFrame.fromEulerAnglesXYZ(math.rad(0.5), math.rad(0.5), math.rad(0.5))
  287.  
  288. end
  289.  
  290. end
  291.  
  292. local x22, y22, z22 = leftHip.C1:toEulerAnglesXYZ()
  293.  
  294. repeat wait() until strikerLoaded
  295.  
  296. gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  297. gyro.Parent = torso
  298. gyro.P = 1500
  299.  
  300. velocity.Parent = torso
  301. velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  302. velocity.P = 125
  303.  
  304. if pos ~= nil then if pos.Parent == torso then pos:remove() end end
  305.  
  306. coroutine.resume(coroutine.create(function()
  307.  
  308. while strikerLoaded do wait(0.03405) if toolSelected and rotationIndice < maxRotation then rotationIndice = rotationIndice + 0.25
  309.  
  310. if desiredSpeed ~= 0 then if desiredSpeed > 0 then motorSpeed = desiredSpeed - (maxRotation - rotationIndice) elseif desiredSpeed < 0 then motorSpeed = desiredSpeed + (maxRotation - rotationIndice) end else motorSpeed = 0 end
  311. if desiredXPartPos ~= 0 then if desiredXPartPos > 0 then xPartPos = desiredXPartPos - (maxRotation/2 - rotationIndice/2) elseif desiredXPartPos < 0 then xPartPos = desiredXPartPos + (maxRotation/2 - rotationIndice/2) end else xPartPos = 0 end
  312. if desiredYPartPos ~= 0 then if desiredYPartPos > 0 then yPartPos = desiredYPartPos - (maxRotation/2 - rotationIndice/2) elseif desiredYPartPos < 0 then yPartPos = desiredYPartPos + (maxRotation/2 - rotationIndice/2) end else yPartPos = 0 end
  313.  
  314. if desiredGyroAngleX ~= 0 then if desiredGyroAngleX > 0 then gyroAngleX = math.rad(desiredGyroAngleX - (maxRotation - rotationIndice)) elseif desiredGyroAngleX < 0 then gyroAngleX = math.rad(desiredGyroAngleX + (maxRotation - rotationIndice)) end else gyroAngleX = 0 end
  315. if desiredGyroAngleY ~= 0 then if desiredGyroAngleY > 0 then gyroAngleY = math.rad(desiredGyroAngleY - (maxRotation - rotationIndice)) elseif desiredGyroAngleY < 0 then gyroAngleY = math.rad(desiredGyroAngleY + (maxRotation - rotationIndice)) end else gyroAngleY = 0 end
  316. if desiredGyroAngleZ ~= 0 then if desiredGyroAngleZ > 0 then gyroAngleZ = math.rad(desiredGyroAngleZ - (maxRotation - rotationIndice)) elseif desiredGyroAngleZ < 0 then gyroAngleZ = math.rad(desiredGyroAngleZ + (maxRotation - rotationIndice)) end else gyroAngleZ = 0 end
  317.  
  318. elseif toolSelected and rotationIndice == maxRotation then humanoid.PlatformStand = true motorSpeed = desiredSpeed gyroAngleX = math.rad(desiredGyroAngleX) gyroAngleY = math.rad(desiredGyroAngleY) gyroAngleZ = math.rad(desiredGyroAngleZ) xPartPos = desiredXPartPos yPartPos = desiredYPartPos end
  319.  
  320. if PropellerOne ~= nil and PWelderOne ~= nil then
  321.  
  322. PWelderOne.C1 = PWelderOne.C1 * CFrame.fromEulerAnglesXYZ(0, -math.rad(rotationIndice), 0)
  323.  
  324. end
  325.  
  326. if PropellerTwo ~= nil and PWelderTwo ~= nil then
  327.  
  328. PWelderTwo.C1 = PWelderTwo.C1 * CFrame.fromEulerAnglesXYZ(0, math.rad(rotationIndice), 0)
  329.  
  330. end
  331.  
  332. if cframePart ~= nil then
  333.  
  334. cframePart.Size = Vector3.new(0.2, 0.2, 0.2)
  335. cframePart.CFrame = CFrame.new(torso.CFrame.p, camera.CoordinateFrame.lookVector * 10000000) + Vector3.new(xPartPos, yPartPos, 0)
  336.  
  337. end
  338.  
  339. if velocity ~= nil then if velocity.Parent == torso then velocity.velocity = (cframePart.CFrame - cframePart.CFrame.p) * Vector3.new(xPartPos, yPartPos, -motorSpeed) end end
  340. if gyro ~= nil then if gyro.Parent == torso then gyro.cframe = CFrame.new(gyro.cframe.p, camera.CoordinateFrame.lookVector * 10000000) * CFrame.fromEulerAnglesXYZ(gyroAngleX, gyroAngleY, gyroAngleZ) end end
  341.  
  342. end return
  343.  
  344. end)) connected = true stand = true
  345.  
  346. mouse.KeyDown:connect(function(key) key = key:lower()
  347.  
  348. if key == "w" then ForwardDown()
  349. elseif key == "s" then BackwardDown()
  350. elseif key == "a" then LeftDown()
  351. elseif key == "d" then RightDown()
  352. elseif key == "e" then UpDown()
  353. elseif key == "q" then DownDown()
  354.  
  355. end end)
  356.  
  357. mouse.KeyUp:connect(function(key) key = key:lower()
  358.  
  359. if key == "w" then ForwardUp() if backward then BackwardDown() end
  360. elseif key == "s" then BackwardUp() if forward then ForwardDown() end
  361. elseif key == "a" then LeftUp() if onright then RightDown() end
  362. elseif key == "d" then RightUp() if onleft then LeftDown() end
  363. elseif key == "e" then UpUp() if ondown then DownDown() end
  364. elseif key == "q" then DownUp() if onup then UpDown() end
  365.  
  366. end end)
  367.  
  368. end
  369.  
  370. function Disconnection()
  371.  
  372. toolSelected = false wait()
  373.  
  374. for index, name in pairs(parts) do
  375.  
  376. if getfenv()[name] ~= nil then
  377.  
  378. coroutine.resume(coroutine.create(function()
  379.  
  380. for i = getfenv()[name].Transparency, 1, 0.1 do wait()
  381.  
  382. getfenv()[name].Transparency = i
  383.  
  384. end
  385.  
  386. end))
  387.  
  388. end
  389.  
  390. end
  391.  
  392. pos.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  393. pos.Parent = torso
  394. pos.position = torso.CFrame.p
  395.  
  396. coroutine.resume(coroutine.create(Striker),0.2)
  397.  
  398. for i = 1, 10, 1 do wait()
  399.  
  400. pos.position = pos.position - Vector3.new(0, 0.15, 0)
  401. humanoid.PlatformStand = true
  402.  
  403. leftHip.C1 = leftHip.C1 * CFrame.new(0, 0.02, 0) * CFrame.fromEulerAnglesXYZ(math.rad(-1), -math.rad(-1), -math.rad(-1))
  404. rightHip.C1 = rightHip.C1 * CFrame.new(0, 0.02, 0) * CFrame.fromEulerAnglesXYZ(math.rad(-1), math.rad(-1), math.rad(-1))
  405.  
  406. end wait()
  407.  
  408. humanoid.PlatformStand = false
  409.  
  410. if pos ~= nil then if pos.Parent == torso then pos:remove() end end
  411. if gyro ~= nil then if gyro.Parent == torso then gyro:remove() end end
  412. if velocity ~= nil then if velocity.Parent == torso then velocity:remove() end end
  413. if mainModel ~= nil then mainModel:remove() end
  414.  
  415. strikerLoaded = false
  416. rotationIndice = 0
  417. motorSpeed = 0
  418. desiredSpeed = 0
  419.  
  420. ForwardUp()
  421. BackwardUp()
  422. LeftUp()
  423. RightUp()
  424.  
  425. forward = false
  426. backward = false
  427. onleft = false
  428. onright = false
  429. onup = false
  430. ondown = false
  431.  
  432. leftHip.C1 = leftHipAngle
  433. rightHip.C1 = rightHipAngle
  434.  
  435. connected = false
  436.  
  437. end
  438.  
  439. function ForwardDown() forward = true
  440.  
  441. desiredGyroAngleX = -maxRotation
  442. desiredSpeed = maxRotation
  443.  
  444. end
  445.  
  446. function BackwardDown() backward = true
  447.  
  448. desiredGyroAngleX = maxRotation
  449. desiredSpeed = -maxRotation
  450.  
  451. end
  452.  
  453. function ForwardUp() forward = false
  454.  
  455. desiredGyroAngleX = 0
  456. desiredSpeed = 0
  457.  
  458. end
  459.  
  460. function BackwardUp() backward = false
  461.  
  462. desiredGyroAngleX = 0
  463. desiredSpeed = 0
  464.  
  465. end
  466.  
  467. function LeftDown() onleft = true
  468.  
  469. desiredGyroAngleY = -maxRotation
  470. desiredXPartPos = -maxRotation/2
  471.  
  472. end
  473.  
  474. function RightDown() onright = true
  475.  
  476. desiredGyroAngleY = maxRotation
  477. desiredXPartPos = maxRotation/2
  478.  
  479. end
  480.  
  481. function LeftUp() onleft = false
  482.  
  483. desiredGyroAngleY = 0
  484. desiredXPartPos = 0
  485.  
  486. end
  487.  
  488. function RightUp() onright = false
  489.  
  490. desiredGyroAngleY = 0
  491. desiredXPartPos = 0
  492.  
  493. end
  494.  
  495. function UpDown() onup = true
  496.  
  497. desiredYPartPos = maxRotation/2
  498.  
  499. end
  500.  
  501. function DownDown() ondown = true
  502.  
  503. desiredYPartPos = -maxRotation/2
  504.  
  505. end
  506.  
  507. function UpUp() onup = false
  508.  
  509. desiredYPartPos = 0
  510.  
  511. end
  512.  
  513. function DownUp() ondown = false
  514.  
  515. desiredYPartPos = 0
  516.  
  517. end
  518.  
  519.  
  520. bin.Selected:connect(Connection)
  521. bin.Deselected:connect(Disconnection)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement