Advertisement
GojiGaming1337

Untitled

Jun 7th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.36 KB | None | 0 0
  1. script:WaitForChild("AT-ST")
  2. local Engine = script["AT-ST"].Value["Engine"]
  3.  
  4. local OriginCF = nil
  5.  
  6. local Sitting = false
  7.  
  8. local MaxSpeed = 0
  9.  
  10. local TurnSpeed = 0
  11. local TurnRot = 0
  12. local LastTurnRot = 0
  13. local Speed = 0
  14. local SideSpeed = 0
  15. local Dampening = 1.5
  16. local MaxPull = 15
  17. local PullRate = 5
  18. local Pull = 0
  19.  
  20. local TrackStep = 1
  21. local TrackWaiting = false
  22.  
  23. local LastBarrel = 2
  24.  
  25. local RocketFireing = false
  26. local RocketReload = 7
  27. local Fireing = false
  28. local Reloading = false
  29. local FireRate = 0.18
  30. local MaxAmmo = 50
  31. local Ammo = MaxAmmo
  32. local ReloadTime = 7
  33.  
  34. local BulletColor = BrickColor.new("Cyan")
  35.  
  36. local Gui = nil
  37.  
  38. local GunRot = 20
  39. local MaxGunRot = 20
  40. local MinGunRot = -40
  41.  
  42. local CabinRot = 0
  43. local MaxCabinRot = 30
  44. local CabinTurning = false
  45.  
  46. local LegsWaiting = false
  47. local Step = 0
  48. local RStep = 0
  49.  
  50.  
  51. function GetMovement()
  52. if script["AT-ST"].Value == nil then
  53. script:remove()
  54. elseif script["AT-ST"].Value.Parent == nil then
  55. script:remove()
  56. end
  57.  
  58. Engine = script["AT-ST"].Value["Engine"]
  59.  
  60. local Seat = Engine.Parent.RotBase["GunnerSeat"]
  61.  
  62. if Seat.Throttle >= 1 then
  63. if Speed < MaxSpeed then
  64. Speed = Speed + 2
  65. end
  66. elseif Seat.Throttle <= -1 then
  67. if Speed > -MaxSpeed then
  68. Speed = Speed - 2
  69. end
  70. elseif Seat.Throttle == 0 then
  71. if Speed > 0 then
  72. Speed = Speed - 2
  73. elseif Speed < 0 then
  74. Speed = Speed + 2
  75. else
  76. Speed = 0
  77. end
  78. end
  79. if Seat.Steer >= 1 then
  80. TurnRot = TurnRot - TurnSpeed
  81. elseif Seat.Steer <= -1 then
  82. TurnRot = TurnRot + TurnSpeed
  83. elseif Seat.Steer == 0 then
  84. TurnRot = TurnRot
  85. LastTurnRot = TurnRot
  86. end
  87. if SideSpeed > 0 then
  88. SideSpeed = SideSpeed - 2
  89. elseif Speed < 0 then
  90. SideSpeed = SideSpeed + 2
  91. else
  92. SideSpeed = 0
  93. end
  94. if Engine["Q"].Value == true then
  95. if SideSpeed < MaxSpeed then
  96. SideSpeed = SideSpeed + 2
  97. end
  98. elseif Engine["E"].Value == true then
  99. if SideSpeed > -MaxSpeed then
  100. SideSpeed = SideSpeed - 2
  101. end
  102. elseif Engine["Q"].Value == false and Engine["E"].Value == false then
  103. if SideSpeed > 0 then
  104. SideSpeed = SideSpeed - 2
  105. elseif Speed < 0 then
  106. SideSpeed = SideSpeed + 2
  107. end
  108. end
  109.  
  110. local ForwardVector = (Engine.CFrame.lookVector * Speed)
  111. local SidewaysVector = ((Engine.CFrame * CFrame.Angles(0, math.rad(90), 0)).lookVector * SideSpeed)
  112.  
  113.  
  114. --if Sitting == true then
  115. --GetAngle()
  116. --else
  117. --Engine.Parent["Rotator"]["BodyGyro"].cframe = (OriginCF * CFrame.Angles(0, math.rad(TurnRot), 0))
  118. --end
  119. Engine["BodyGyro"].cframe = (OriginCF * CFrame.Angles(0, math.rad(TurnRot), 0))
  120. Engine["BodyGyro"].maxTorque = Vector3.new(400000, 400000, 400000)
  121.  
  122. Engine["BodyVelocity"].velocity = (Engine.CFrame.lookVector * Speed)
  123. Engine["BodyVelocity"].maxForce = Vector3.new(40000000, 1000, 40000000)
  124. end
  125.  
  126. function GetAngle()
  127. local MaxDist = (((Engine.CFrame * CFrame.Angles(0, math.rad(MaxCabinRot), 0)) * CFrame.new(0, 0, 1)).p - (Engine.CFrame * CFrame.new(0, 0, 1)).p).magnitude
  128.  
  129. local Direction = 0
  130. local LeftPoint = ((Engine.CFrame * CFrame.Angles(0, math.rad(90), 0)) * CFrame.new(0, 0, 1)).p
  131. local RightPoint = ((Engine.CFrame * CFrame.Angles(0, math.rad(-90), 0)) * CFrame.new(0, 0, 1)).p
  132.  
  133. local Cam = game.Workspace.CurrentCamera
  134. local CamPos = Cam.CoordinateFrame.p
  135. local CamFoc = Cam.Focus.p
  136.  
  137. local FacingCF = CFrame.new(Vector3.new(CamPos.x, 0, CamPos.z), Vector3.new(CamFoc.x, 0, CamFoc.z))
  138.  
  139. local LeftDist = (LeftPoint - (FacingCF * CFrame.new(0, 0, 1)).p).magnitude
  140. local RightDist = (RightPoint - (FacingCF * CFrame.new(0, 0, 1)).p).magnitude
  141.  
  142. if LeftDist < RightDist then
  143. Direction = 1
  144. elseif RightDist < LeftDist then
  145. Direction = -1
  146. else
  147. Direction = 0
  148. end
  149.  
  150. local Dist = (LeftPoint - (Engine.CFrame * CFrame.new(0, 0, 1)).p).magnitude
  151.  
  152. local AngleCF = nil
  153. if Dist > MaxDist then
  154. AngleCF = (Engine.CFrame * CFrame.Angles(0, math.rad(MaxCabinRot * Direction), 0))
  155. else
  156. AngleCF = FacingCF
  157. end
  158.  
  159. Engine.Parent["Rotator"]["BodyGyro"].cframe = AngleCF
  160. end
  161.  
  162. function OldGetRotGun()
  163. if Sitting == true then
  164. local Mouse = game.Players.LocalPlayer:GetMouse()
  165. Mouse.TargetFilter = Engine.Parent
  166. local CameraCF = CFrame.new(Engine.Parent["RotGun"]["Rot"].Position, (CFrame.new(Engine.Parent["RotGun"]["Rot"].Position, Mouse.Hit.p) * CFrame.new(0, 0, -1000)).p)
  167. local RX, RY, RZ = CameraCF:toEulerAnglesXYZ()
  168. local EX, EY, EZ = Engine.CFrame:toEulerAnglesXYZ()
  169.  
  170. local Rotation = (CameraCF - CameraCF.p)
  171.  
  172. Engine.Parent["RotBase"]["Rot"]["BodyGyro"].cframe = Rotation
  173. Engine.Parent["RotBase"]["Rot"]["BodyGyro"].maxTorque = Vector3.new(0, 40000, 0)
  174.  
  175. Engine.Parent["RotBase"]["Rot"]["BodyGyro2"].cframe = Engine.CFrame
  176. Engine.Parent["RotBase"]["Rot"]["BodyGyro2"].maxTorque = Vector3.new(40000, 0, 40000)
  177.  
  178. Engine.Parent["RotGun"]["Rot"]["BodyGyro"].cframe = Rotation
  179. Engine.Parent["RotGun"]["Rot"]["BodyGyro"].maxTorque = Vector3.new(400, 0, 400)
  180. else
  181. Engine.Parent["RotBase"]["Rot"]["BodyGyro"].cframe = Engine.CFrame
  182. Engine.Parent["RotBase"]["Rot"]["BodyGyro"].maxTorque = Vector3.new(0, 40000, 0)
  183.  
  184. Engine.Parent["RotBase"]["Rot"]["BodyGyro2"].cframe = Engine.CFrame
  185. Engine.Parent["RotBase"]["Rot"]["BodyGyro2"].maxTorque = Vector3.new(40000, 0, 40000)
  186.  
  187. Engine.Parent["RotGun"]["Rot"]["BodyGyro"].cframe = Engine.CFrame
  188. Engine.Parent["RotGun"]["Rot"]["BodyGyro"].maxTorque = Vector3.new(400, 0, 400)
  189. end
  190. end
  191.  
  192. function GetRotGun()
  193. if Sitting == true then
  194. local Mouse = game.Players.LocalPlayer:GetMouse()
  195. Mouse.TargetFilter = Engine.Parent
  196. if (Vector3.new(Mouse.Hit.x, Engine.Position.Y, Mouse.Hit.z) - Engine.Position).magnitude <= 30 and Mouse.Hit.y <= Engine.Parent["RotGun"]["Rot"].Position.Y then
  197. Engine = Engine
  198. else
  199. local CameraCF = CFrame.new(Engine.Parent["RotGun"]["Rot"].Position, (CFrame.new(Engine.Parent["RotGun"]["Rot"].Position, Mouse.Hit.p) * CFrame.new(0, 0, -1000)).p)
  200. local RX, RY, RZ = CameraCF:toEulerAnglesXYZ()
  201. local EX, EY, EZ = Engine.CFrame:toEulerAnglesXYZ()
  202.  
  203. local Rotation = (CameraCF - CameraCF.p)
  204.  
  205. Engine.Parent["RotBase"]["Rot"]["BodyGyro"].cframe = Rotation
  206. Engine.Parent["RotBase"]["Rot"]["BodyGyro"].maxTorque = Vector3.new(0, 40000, 0)
  207.  
  208. Engine.Parent["RotBase"]["Rot"]["BodyGyro2"].cframe = Engine.CFrame
  209. Engine.Parent["RotBase"]["Rot"]["BodyGyro2"].maxTorque = Vector3.new(40000, 0, 40000)
  210.  
  211. Engine.Parent["RotGun"]["Rot"]["BodyGyro"].cframe = Rotation
  212. Engine.Parent["RotGun"]["Rot"]["BodyGyro"].maxTorque = Vector3.new(400, 0, 400)
  213. end
  214. else
  215. Engine.Parent["RotBase"]["Rot"]["BodyGyro"].cframe = Engine.CFrame
  216. Engine.Parent["RotBase"]["Rot"]["BodyGyro"].maxTorque = Vector3.new(0, 40000, 0)
  217.  
  218. Engine.Parent["RotBase"]["Rot"]["BodyGyro2"].cframe = Engine.CFrame
  219. Engine.Parent["RotBase"]["Rot"]["BodyGyro2"].maxTorque = Vector3.new(40000, 0, 40000)
  220.  
  221. Engine.Parent["RotGun"]["Rot"]["BodyGyro"].cframe = Engine.CFrame
  222. Engine.Parent["RotGun"]["Rot"]["BodyGyro"].maxTorque = Vector3.new(400, 0, 400)
  223. end
  224. end
  225.  
  226. function UpdateGui()
  227. coroutine.resume(coroutine.create(function()
  228. if Gui == nil then
  229. if game.Players.LocalPlayer.PlayerGui:findFirstChild("WeaponHud") ~= nil then
  230. Gui = game.Players.LocalPlayer.PlayerGui["WeaponHud"]
  231. else
  232. Gui = script["WeaponHud"]:clone()
  233. Gui.Parent = game.Players.LocalPlayer.PlayerGui
  234. for i, v in pairs(Gui:GetChildren()) do
  235. coroutine.resume(coroutine.create(function()
  236. v.Visible = true
  237. end))
  238. end
  239. end
  240. end
  241. Gui["MainFrame"]["Frame"]["WeaponName"].Text = "Turbolaser"
  242. if Ammo ~= MaxAmmo then
  243. Gui["MainFrame"]["Frame"]["BarFrame"]["Bar"].Size = UDim2.new(((1 / MaxAmmo) * (Ammo)), 0, 1, 0)
  244. else
  245. Gui["MainFrame"]["Frame"]["BarFrame"]["Bar"].Size = UDim2.new(1, 0, 1, 0)
  246. --Gui["Bar"]["Fill"].BackgroundColor3 = Color3.new(1, 0, 0)
  247. end
  248. local Percent = (((1 / MaxAmmo) * (Ammo)) * 100)
  249. local PercentText = tostring(Percent)
  250. if PercentText:sub(1):find(".") and PercentText ~= "100" then
  251. if Percent < 10 then
  252. PercentText = PercentText:sub(1, PercentText:sub(1):find("."))
  253. else
  254. PercentText = PercentText:sub(1, PercentText:sub(1):find(".") + 1)
  255. end
  256. end
  257. wait(0.1)
  258. if Reloading == false then
  259. Gui["MainFrame"]["Frame"]["Percent"].Text = PercentText .. "%"
  260. else
  261. Gui["MainFrame"]["Frame"]["Percent"].Text = "RELOADING..."
  262. end
  263. end))
  264. end
  265.  
  266. function TestForLightsaber(Human, BulletPos, BulletHitPos)
  267. local ToReturn = false
  268. coroutine.resume(coroutine.create(function()
  269. local LightsaberFound = false
  270. local FoundLightsaber = nil
  271. if Human.Parent:findFirstChild("LightsaberEquipped") ~= nil then
  272. LightsaberFound = true
  273. FoundLightsaber = Human.Parent["LightsaberEquipped"].Value
  274. end
  275. local BlockDist = 0.15
  276. if LightsaberFound == true then
  277. if FoundLightsaber:findFirstChild("BlockPrecentage") ~= nil then
  278. BlockDist = FoundLightsaber["BlockPrecentage"].Value
  279. else
  280. BlockDist = 0.15
  281. end
  282. end
  283. if LightsaberFound == true then
  284. local TheHandle = FoundLightsaber["Handle"]
  285. local Char = Human.Parent
  286. local Char2 = game.Players.LocalPlayer.Character
  287. local LookCF = CFrame.new(Vector3.new(TheHandle.Position.X, BulletPos.y, TheHandle.Position.Z), Vector3.new(Char["Torso"].Position.X, BulletPos.y, Char["Torso"].Position.Z))
  288. local Ray = Ray.new(LookCF.p, (LookCF * CFrame.new(0, 0, -999)).p - LookCF.p)
  289. local DistFromBullet = (Vector3.new(TheHandle.Position.X, BulletPos.y, TheHandle.Position.Z) - Vector3.new(Char2["Torso"].Position.X, BulletPos.y, Char2["Torso"].Position.Z)).magnitude
  290. local CP = Ray:ClosestPoint(Vector3.new(BulletHitPos.x, BulletPos.y, BulletHitPos.z))
  291. local DistFromCP = (Vector3.new(BulletHitPos.x, BulletPos.y, BulletHitPos.z) - Vector3.new(TheHandle.Position.X, BulletPos.y, TheHandle.Position.Z)).magnitude
  292. if DistFromCP <= (DistFromBullet * BlockDist) then
  293. ToReturn = true
  294. end
  295. end
  296. if LightsaberFound == true then
  297. if FoundLightsaber:findFirstChild("Handle3") then
  298. local TheHandle = FoundLightsaber["Handle3"]
  299. local Char = Human.Parent
  300. local Char2 = game.Players.LocalPlayer.Character
  301. local LookCF = CFrame.new(Vector3.new(TheHandle.Position.X, BulletPos.y, TheHandle.Position.Z), Vector3.new(Char["Torso"].Position.X, BulletPos.y, Char["Torso"].Position.Z))
  302. local Ray = Ray.new(LookCF.p, (LookCF * CFrame.new(0, 0, -999)).p - LookCF.p)
  303. local DistFromBullet = (Vector3.new(TheHandle.Position.X, BulletPos.y, TheHandle.Position.Z) - Vector3.new(Char2["Torso"].Position.X, BulletPos.y, Char2["Torso"].Position.Z)).magnitude
  304. local CP = Ray:ClosestPoint(Vector3.new(BulletHitPos.x, BulletPos.y, BulletHitPos.z))
  305. local DistFromCP = (Vector3.new(BulletHitPos.x, BulletPos.y, BulletHitPos.z) - Vector3.new(TheHandle.Position.X, BulletPos.y, TheHandle.Position.Z)).magnitude
  306. if DistFromCP <= (DistFromBullet * BlockDist) then
  307. ToReturn = true
  308. end
  309. end
  310. end
  311. if (math.random(0, 10) * 0.1) > (BlockDist * 2.25) then
  312. ToReturn = false
  313. end
  314. end))
  315. return ToReturn
  316. end
  317.  
  318. function FireWeapon(Type)
  319. coroutine.resume(coroutine.create(function()
  320.  
  321. function FireRotGun(TargetPos)
  322.  
  323. if Ammo <= 0 or Reloading == true then
  324. if Reloading == false then
  325. Reloading = true
  326. UpdateGui()
  327. wait(ReloadTime)
  328. Ammo = MaxAmmo
  329. Reloading = false
  330. wait(0.1)
  331. UpdateGui()
  332. end
  333. else
  334.  
  335. local Damage = 25
  336. local DamageRange = 5
  337. local AccuricyRange = 2
  338. local TeamKill = false
  339.  
  340.  
  341. local Barrels = {Engine.Parent["RotGun"]["Barrel1"]}
  342. for i, Barrel in pairs(Barrels) do
  343. coroutine.resume(coroutine.create(function()
  344.  
  345. local BulletsModel = Engine
  346. local Bullet = Barrel:clone()
  347. Bullet["PointLight"]:remove()
  348. Bullet["Flash"]:remove()
  349. Bullet["Mesh"]:remove()
  350. Bullet.Name = "Bullet"
  351. Bullet.Parent = BulletsModel
  352. Bullet.Anchored = true
  353. Bullet.CanCollide = false
  354. Bullet.Material = "Neon"
  355. Bullet.FormFactor = "Custom"
  356. Bullet.Transparency = 1
  357. Bullet.Size = Vector3.new(2, 2, 1)
  358. local BulletMesh = Instance.new("BlockMesh", Bullet)
  359.  
  360. local Bullet2 = Bullet:clone()
  361. Bullet2.Parent = Bullet.Parent
  362.  
  363. local LightPart = Bullet2:clone()
  364. LightPart.Parent = Bullet2.Parent
  365. local LightPartLight = Barrel["PointLight"]:clone()
  366. LightPartLight.Parent = LightPart
  367.  
  368.  
  369. if game.Players.LocalPlayer.Character["Humanoid"].Health > 0 then
  370. --coroutine.resume(coroutine.create(function()
  371. if Reloading == false and Ammo > 0 then
  372.  
  373. local RotX = (math.random(-(AccuricyRange * 5), (AccuricyRange * 5)) * 0.1)
  374. local RotY = (math.random(-(AccuricyRange * 5), (AccuricyRange * 5)) * 0.1)
  375. local DirectionCF = CFrame.new(Barrel.Position, TargetPos) * CFrame.Angles(math.rad(RotX), math.rad(RotY), 0)
  376. local Dist = 1000
  377. local Ray = Ray.new(Barrel.Position, (DirectionCF * CFrame.new(0, 0, -1000)).p - Barrel.Position)
  378. local Hit, Pos = game.Workspace:FindPartOnRay(Ray, game.Players.LocalPlayer.Character)
  379. if Hit ~= nil then
  380. Dist = (Pos - Barrel.Position).magnitude
  381. LightPart.CFrame = (DirectionCF * CFrame.new(0, 0, -(Dist - 1))) * CFrame.Angles(math.rad(-90), 0, 0)
  382. local Human = nil
  383. if Hit.Parent:findFirstChild("Humanoid") then
  384. Human = Hit.Parent["Humanoid"]
  385. elseif Hit.Parent.Parent:findFirstChild("Humanoid") then
  386. Human = Hit.Parent.Parent["Humanoid"]
  387. end
  388. if Human ~= nil then
  389. coroutine.resume(coroutine.create(function()
  390. local BulletBlocked = false
  391. local BlockedBySaber = TestForLightsaber(Human, DirectionCF.p, Pos)
  392. if BlockedBySaber == true then
  393. BulletBlocked = true
  394. end
  395. if BulletBlocked == false then
  396. local EPlayer = game.Players:GetPlayerFromCharacter(Human.Parent)
  397. local DamageHuman = true
  398. if EPlayer ~= nil then
  399. if EPlayer.TeamColor == game.Players.LocalPlayer.TeamColor and TeamKill == false then
  400. DamageHuman = false
  401. end
  402. end
  403. --wait(0.01)
  404. if DamageHuman == true and Human.Parent:findFirstChild("ForceField") == nil then
  405. Human.Health = Human.Health - (math.random((Damage - DamageRange) * 10, (Damage + DamageRange) * 10) * 0.1)
  406. if Human.Health <= 0 then
  407. if Human:findFirstChild("creator") == nil then
  408. local CreatorValue = Instance.new("ObjectValue", Human)
  409. CreatorValue.Name = "creator"
  410. CreatorValue.Value = game.Players.LocalPlayer
  411. end
  412. end
  413. end
  414. end
  415. end))
  416. end
  417. end
  418.  
  419. coroutine.resume(coroutine.create(function()
  420. Bullet.CFrame = DirectionCF
  421. Bullet2.CFrame = DirectionCF
  422. Barrel["Fire"]:Play()
  423. Barrel["PointLight"].Enabled = true
  424. if BulletColor == nil then
  425. Bullet.BrickColor = game.Players.LocalPlayer.TeamColor
  426. else
  427. Bullet.BrickColor = BulletColor
  428. end
  429. Bullet2.BrickColor = BrickColor.new("Institutional white")
  430. Barrel["PointLight"].Color = Bullet.BrickColor.Color
  431. LightPartLight.Color = Barrel["PointLight"].Color
  432. Bullet.Transparency = 0.35
  433. Bullet2.Transparency = 0.2
  434. wait(0.03)
  435. LightPartLight.Enabled = false
  436. Bullet.Transparency = 1
  437. Bullet2.Transparency = 1
  438. Barrel["Flash"]["Flash"].Visible = false
  439. Barrel["PointLight"].Enabled = false
  440.  
  441. Bullet:Destroy()
  442. Bullet2:Destroy()
  443. LightPart:Destroy()
  444. end))
  445.  
  446. BulletMesh.Scale = Vector3.new(0.4, 0.4, Dist)
  447. BulletMesh.Offset = Vector3.new(0, 0, -(Dist / 2))
  448. Bullet2["Mesh"].Scale = Vector3.new(0.25, 0.25, Dist)
  449. Bullet2["Mesh"].Offset = Vector3.new(0, 0, -(Dist / 2))
  450.  
  451. end
  452. --end))
  453. end
  454. end))
  455.  
  456. wait(0.04)
  457.  
  458. end
  459.  
  460. Ammo = Ammo - 1
  461.  
  462. wait(FireRate)
  463.  
  464. end
  465.  
  466. end
  467.  
  468. function Smoke(Missile)
  469. for i = 1, 5 do
  470. local Smoke = script["Smoke"]:clone()
  471. Smoke.Parent = Missile
  472. Smoke.Size = (math.random(300,400) * 0.01)
  473. wait(0.01)
  474. end
  475. end
  476.  
  477. function FireRocket(TargetPos)
  478. if RocketFireing == true then return end
  479. RocketFireing = true
  480.  
  481. coroutine.resume(coroutine.create(function()
  482. if game.Players.LocalPlayer.Character["Humanoid"].Health > 0 then
  483. coroutine.resume(coroutine.create(function()
  484.  
  485. local Barrel = Engine.Parent["RotGun"]["RBarrel"]
  486.  
  487. local LookCF = CFrame.new(Barrel.Position, TargetPos) * CFrame.Angles(math.rad(2.5), 0, 0)
  488.  
  489. local Missile = Instance.new("Part", game.Workspace)
  490. Missile.Shape = "Ball"
  491. Missile.Anchored = true
  492. Missile.CanCollide = false
  493. Missile.Transparency = 1
  494. Missile.Size = Vector3.new(1, 1, 1)
  495. Missile.CFrame = LookCF
  496. Missile.Velocity = (CFrame.new(Missile.Position, (LookCF * CFrame.new(0, 0, -10)).p).lookVector * 150)
  497.  
  498. coroutine.resume(coroutine.create(function()
  499. Smoke(Missile)
  500. end))
  501. wait(0.1)
  502. Missile.Anchored = false
  503.  
  504. script:WaitForChild("Light")
  505. local Light = script["Light"]:clone()
  506. Light.Parent = Missile
  507. local CFValue = Instance.new("CFrameValue", Missile)
  508. CFValue.Name = "OriginCFrame"
  509. CFValue.Value = (LookCF * CFrame.new(0, 0, -10))
  510. local LocalPlayerValue = Instance.new("ObjectValue", Missile)
  511. LocalPlayerValue.Name = "LocalPlayer"
  512. LocalPlayerValue.Value = game.Players.LocalPlayer
  513. local TeamColorValue = Instance.new("BrickColorValue", Missile)
  514. TeamColorValue.Name = "TeamColor"
  515. TeamColorValue.Value = game.Players.LocalPlayer.TeamColor
  516. script:WaitForChild("Effect")
  517. local Effect = script["Effect"]:clone()
  518. Effect.Parent = Missile
  519. Effect.Disabled = false
  520.  
  521. end))
  522. end
  523. end))
  524.  
  525. UpdateGui()
  526. wait(RocketReload)
  527. RocketFireing = false
  528. UpdateGui()
  529. end
  530.  
  531.  
  532. if Type == "Rocket" then
  533. local Mouse = game.Players.LocalPlayer:GetMouse()
  534. FireRocket(Mouse.Hit.p)
  535. UpdateGui()
  536. elseif Type == "Bullet" then
  537. while Fireing == true do
  538. local Mouse = game.Players.LocalPlayer:GetMouse()
  539. FireRotGun(Mouse.Hit.p)
  540. UpdateGui()
  541. wait(0.02)
  542. end
  543. UpdateGui()
  544. end
  545.  
  546. end))
  547. end
  548.  
  549. function Keys()
  550. local Mouse = nil
  551. coroutine.resume(coroutine.create(function()
  552. local NewMouse = game.Players.LocalPlayer:GetMouse()
  553. if NewMouse ~= Mouse then
  554. Mouse = NewMouse
  555. Mouse.KeyDown:connect(function(key)
  556. if Sitting == true then
  557. if key == "q" then
  558. CabinTurning = true
  559. repeat
  560. if CabinRot < MaxCabinRot then
  561. CabinRot = CabinRot + 2
  562. end
  563. wait(0.02)
  564. until CabinTurning == false
  565. elseif key == "e" then
  566. CabinTurning = true
  567. repeat
  568. if CabinRot > -MaxCabinRot then
  569. CabinRot = CabinRot - 2
  570. end
  571. wait(0.02)
  572. until CabinTurning == false
  573. elseif key == "c" then
  574. CabinRot = 0
  575. elseif key == "r" then
  576. if Reloading == false then
  577. Reloading = true
  578. UpdateGui()
  579. wait(ReloadTime)
  580. Ammo = MaxAmmo
  581. Reloading = false
  582. wait(0.1)
  583. UpdateGui()
  584. end
  585. elseif key == "f" then
  586. if RocketFireing == false then
  587. FireWeapon("Rocket")
  588. end
  589. end
  590. end
  591. end)
  592. Mouse.KeyUp:connect(function(key)
  593. if Sitting == true then
  594. if key == "q" then
  595. CabinTurning = false
  596. elseif key == "e" then
  597. CabinTurning = false
  598. end
  599. end
  600. end)
  601. Mouse.Button1Down:connect(function()
  602. if Sitting == true then
  603. Mouse.Button1Up:connect(function()
  604. Fireing = false
  605. end)
  606. Fireing = true
  607. FireWeapon("Bullet")
  608. end
  609. end)
  610. end
  611. end))
  612. end
  613.  
  614. Keys()
  615.  
  616. function GetHealth()
  617. local Human = Engine.Parent["Humanoid"]
  618. if (Human.Health / Human.MaxHealth) <= 0.2 then
  619. Engine["Smoke"].Enabled = true
  620. Engine["Smoke"].Opacity = ((1 / (Human.Health / Human.MaxHealth)) * (Human.Health / Human.MaxHealth))
  621. end
  622. if Human.Health <= 1 then
  623. Engine["BodyGyro"].maxTorque = Vector3.new(0, 0, 0)
  624. Engine["BodyVelocity"].maxForce = Vector3.new(0, 0, 0)
  625. function Corrode(Item)
  626. local Waiting = false
  627. local Waiting2 = false
  628. for i, v in pairs(Item:GetChildren()) do
  629. if v:IsA("BasePart") and v.Name ~= "Engine" then
  630. local Rand = math.random(1,2)
  631. if Rand == 1 then
  632. v.Material = "CorrodedMetal"
  633. v:BreakJoints()
  634. end
  635. else
  636. if v:IsA("Model") then
  637. Corrode(v)
  638. end
  639. end
  640. if Waiting == false then
  641. Waiting = true
  642. if Waiting2 == false then
  643. Waiting2 = true
  644. wait(0.01)
  645. else
  646. Waiting2 = false
  647. end
  648. else
  649. Waiting = false
  650. end
  651. end
  652. end
  653. Corrode(Engine.Parent)
  654. local ex = Instance.new("Explosion", game.Workspace)
  655. ex.Position = Engine.Position
  656. ex.BlastRadius = 15
  657. ex.BlastPressure = 10000
  658. ex.DestroyJointRadiusPercent = 0
  659. wait(10)
  660. coroutine.resume(coroutine.create(function()
  661. game.Players.LocalPlayer.Character["AT-STVehicle"]:remove()
  662. end))
  663. script:remove()
  664. end
  665. end
  666.  
  667. function Sit(Item)
  668. local plr = game.Players:GetPlayerFromCharacter(Engine.Parent.Parent.Parent)
  669. if Item.Name == "SeatWeld" then
  670. if Item.Part1.Parent:findFirstChild("Humanoid") ~= nil then
  671. if Item.Part1.Parent["Humanoid"] ~= plr.Character["Humanoid"] then
  672. --print("NOT ALLOWED!")
  673. wait(0.1)
  674. Item.Part1.Parent["Humanoid"].Sit = false
  675. else
  676. Sitting = true
  677. UpdateGui()
  678. if plr ~= nil then
  679. Engine.Parent.RotBase["GunnerSeat"].ChildRemoved:connect(function(Item2)
  680. if Item2 == Item then
  681. Sitting = false
  682. if Gui ~= nil then
  683. Gui:remove()
  684. Gui = nil
  685. end
  686. end
  687. end)
  688. end
  689. end
  690. end
  691. end
  692. end
  693.  
  694. Engine.Parent.RotBase["GunnerSeat"].ChildAdded:connect(Sit)
  695.  
  696. TurnRot = Engine.Rotation.Y
  697.  
  698. OriginCF = Engine.CFrame
  699.  
  700. --GetMovement()
  701.  
  702. for i, v in pairs(script["WeaponHud"]:GetChildren()) do
  703. coroutine.resume(coroutine.create(function()
  704. v.Visible = false
  705. end))
  706. end
  707.  
  708. local ff = Instance.new("ForceField", Engine.Parent)
  709.  
  710. wait(1)
  711.  
  712. repeat
  713. Engine.Parent["Humanoid"].Health = Engine.Parent["Humanoid"].MaxHealth
  714. wait(0.01)
  715. until Engine.Parent["Humanoid"].Health == Engine.Parent["Humanoid"].MaxHealth
  716.  
  717. ff:remove()
  718.  
  719. while true do
  720. GetMovement()
  721. GetRotGun()
  722. GetHealth()
  723. wait(0.01)
  724. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement