Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.80 KB | None | 0 0
  1. -- TRA Test Tank Script
  2.  
  3. local vehicleName = "Mk6 MBT"
  4.  
  5. local vehicle = script.Parent
  6.  
  7. -- References
  8. local base = vehicle:FindFirstChild("Base")
  9. local vehicleSeat = vehicle:WaitForChild("VehicleSeat")
  10. local turretAxle = vehicle:WaitForChild("TurretAxle")
  11. local barrelAxle = vehicle:WaitForChild("BarrelAxle")
  12. local leftThrust = vehicle:WaitForChild("LeftThrust")
  13. local leftBodyThrust = leftThrust:WaitForChild("BodyThrust")
  14. local rightThrust = vehicle:WaitForChild("RightThrust")
  15. local rightBodyThrust = rightThrust:WaitForChild("BodyThrust")
  16. local barrelBreach = vehicle:WaitForChild("Barrel"):WaitForChild("BarrelBreach")
  17. local barrelTip = vehicle:WaitForChild("Barrel"):WaitForChild("BarrelTip")
  18. -- Children References
  19. local bodyParts = vehicle:WaitForChild("Body"):GetChildren()
  20. local turretParts = vehicle:WaitForChild("Turret"):GetChildren()
  21. local barrelParts = vehicle:WaitForChild("Barrel"):GetChildren()
  22. local leftWheels = vehicle:WaitForChild("LeftWheels"):GetChildren()
  23. local rightWheels = vehicle:WaitForChild("RightWheels"):GetChildren()
  24. -- Aiming Values
  25. local aim = script:WaitForChild("Aim")
  26. local target = script:WaitForChild("Target")
  27. -- Sounds
  28. local engineSound = vehicleSeat:FindFirstChild("Engine")
  29. local mainGunFire = vehicleSeat:FindFirstChild("MainGunFire")
  30. local reload = vehicleSeat:FindFirstChild("Reload")
  31. local turn = vehicleSeat:FindFirstChild("Turn")
  32.  
  33. -- VEHICLE STATISTICS
  34.  
  35. -- Torque of each wheel
  36. local torque = 900000
  37. -- Maximum speed of the vehicle
  38. local maxVelocity = vehicleSeat.MaxSpeed*.65
  39. -- Acceleration
  40. local maxAcceleration = 30
  41. -- How much force for each suspension wheel
  42. local suspensionForce = 200000
  43. -- Maximum length of the suspension springs
  44. local suspensionMaxLength = 4.24
  45. -- Minimum length of the suspension springs
  46. local suspensionMinLength = 0.5
  47. -- Dampening of the suspension spring
  48. local suspensionDamping = 15
  49. -- Stiffness of the suspension springs
  50. local suspensionStiffness = 7000
  51. -- Idle distance of the suspension when no force is applied
  52. local suspensionFreeLength = 4
  53. -- Turn Sharpness - How easily the vehicle can turn
  54. local turnSharpness = 8
  55. -- Turn Sharpness Stationary - How easily the vehicle can turn when stationary, usually turnSharpness/2
  56. local stationaryTurnSharpness = 4
  57.  
  58. -- Set at 0
  59. local suspensionLowAngle = 0
  60. -- How much the suspension can raise when pressured on
  61. local suspensionHighAngle = -30
  62.  
  63. -- Turret traversal speed in degrees/second
  64. local traversalSpeed = 30
  65. -- Gun elevation speed in degrees/second
  66. local elevationSpeed = 5
  67. -- Maximum elevation
  68. local maxElevation = 25
  69. -- Minimum elevation
  70. local minElevation = -10
  71. -- Inverse smoothness of turret traversal and rotation
  72. local smoothness = 30
  73.  
  74. -- Force for each boat thruster for aquatic capabilities
  75. local boatForce = 13000
  76.  
  77.  
  78. -- Weld together a and b
  79. function weldTogether(a, b, parent)
  80. local CJ = CFrame.new(a.Position)
  81. local C0 = a.CFrame:inverse()*CJ
  82. local C1 = b.CFrame:inverse()*CJ
  83. local weld = Instance.new("Weld", parent)
  84. weld.C0 = a.CFrame:toObjectSpace(b.CFrame)
  85. weld.Part0 = a
  86. weld.Part1 = b
  87. b.Anchored = false
  88. return weld
  89. end
  90.  
  91. -- Configure the HingeConstraints
  92. for i = 1, #leftWheels do
  93. local subject = leftWheels[i]
  94. if subject.Name == "Stationary" then
  95. local axle = subject:FindFirstChild("Axle")
  96. local wheel = subject:FindFirstChild("Wheel")
  97. -- Axle to Wheel
  98. local axleAttachment = Instance.new("Attachment", axle)
  99. axleAttachment.Name = "AxleAttachment"
  100. axleAttachment.Position = Vector3.new(0,0,0)
  101. local wheelAttachment = Instance.new("Attachment", wheel)
  102. wheelAttachment.Name = "WheelAttachment"
  103. wheelAttachment.Position = Vector3.new(0,0,0)
  104. local wheelMotor = Instance.new("HingeConstraint", subject.Parent)
  105. wheelMotor.Name = "WheelMotor"
  106. wheelMotor.ActuatorType = "Motor"
  107. wheelMotor.Attachment0 = axleAttachment
  108. wheelMotor.Attachment1 = wheelAttachment
  109. wheelMotor.Enabled = true
  110. wheelMotor.AngularVelocity = 0
  111. wheelMotor.MotorMaxTorque = torque
  112. wheelMotor.MotorMaxAcceleration = maxAcceleration
  113. weldTogether(base,axle,axle)
  114. axle.Anchroed = false
  115. wheel.Anchored = false
  116. elseif subject.Name == "FrontTurn" or subject.Name == "BackTurn" then
  117. local pivot = rightWheels[i]:FindFirstChild("Pivot")
  118. local axle = rightWheels[i]:FindFirstChild("Axle")
  119. local wheel = rightWheels[i]:FindFirstChild("Wheel")
  120. local axleAttachment = Instance.new("Attachment", axle)
  121. axleAttachment.Name = "AxleAttachment"
  122. axleAttachment.Position = Vector3.new(0,0,0)
  123. local wheelAttachment = Instance.new("Attachment", wheel)
  124. wheelAttachment.Name = "WheelAttachment"
  125. wheelAttachment.Position = Vector3.new(0,0,0)
  126. local wheelMotor = Instance.new("HingeConstraint", subject.Parent)
  127. wheelMotor.Name = "WheelMotor"
  128. wheelMotor.ActuatorType = "Motor"
  129. wheelMotor.Attachment0 = axleAttachment
  130. wheelMotor.Attachment1 = wheelAttachment
  131. wheelMotor.Enabled = true
  132. wheelMotor.AngularVelocity = 0
  133. wheelMotor.MotorMaxTorque = torque
  134. wheelMotor.MotorMaxAcceleration = maxAcceleration
  135. weldTogether(tire,wheel,tire)
  136. local turnWeld = weldTogether(axle,pivot,subject.Parent)
  137. if subject.Name == "FrontTurn" then
  138. turnWeld.Name == "FrontTurnWeld"
  139. else
  140. subject.Name == "BackTurnWeld"
  141. weldTogether(base,pivot,pivot)
  142. pivot.Anchored = false
  143. axle.Anchored = false
  144. wheel.Anchored = false
  145. elseif subject.Name == "Suspension" then
  146. local frame = subject:FindFirstChild("Frame")
  147. local lever = subject:FindFirstChild("Lever")
  148. local wheel = subject:FindFirstChild("Wheel")
  149. -- Pivot Movement
  150. local pivotLeverAttachment = Instance.new("Attachment", lever)
  151. pivotLeverAttachment.Name = "PivotLeverAttachment"
  152. pivotLeverAttachment.Position = Vector3.new(0,1.25,-1.25)
  153. local pivotFrameAttachment = Instance.new("Attachment",frame)
  154. pivotFrameAttachment.Name = "PivotFrameAttachment"
  155. pivotFrameAttachment.Position = Vector3.new(0,0.25,-1.25)
  156. local suspensionPivot = Instance.new("HingeConstraint", frame)
  157. suspensionPivot.Name = "SuspensionPivot"
  158. suspensionPivot.Attachment0 = pivotFrameAttachment
  159. suspensionPivot.Attachment1 = pivotLeverAttachment
  160. suspensionPivot.LimitsEnabled = true
  161. suspensionPivot.LowerAngle = suspensionLowAngle
  162. suspensionPivot.UpperAngle = suspensionHighAngle
  163. -- Wheel Rotation
  164. local wheelAttachment = Instance.new("Attachment", wheel)
  165. wheelAttachment.Name = "WheelAttachment"
  166. wheelAttachment.Position = Vector3.new(0,0,0)
  167. local axleLeverAttachment = Instance.new("Attachment", lever)
  168. axleLeverAttachment.Name = "AxleLeverAttachment"
  169. axleLeverAttachment.Position = Vector3.new(0,-1.25,1.25)
  170. local wheelMotor = Instance.new("HingeConstraint", subject.Parent)
  171. wheelMotor.Name = "WheelMotor"
  172. wheelMotor.ActuatorType = "Motor"
  173. wheelMotor.Attachment0 = axleLeverAttachment
  174. wheelMotor.Attachment1 = wheelAttachment
  175. wheelMotor.AngularVelocity = 0
  176. wheelMotor.MotorMaxTorque = torque
  177. wheelMotor.MotorMaxAcceleration = maxAcceleration
  178. -- Spring Suspension
  179. local springFrameAttachment = Instance.new("Attachment", frame)
  180. springFrameAttachment.Name = "SpringFrameAttachment"
  181. springFrameAttachment.Position = Vector3.new(0,0.25,1.25)
  182. local springSuspension = Instance.new("SpringConstraint",frame)
  183. springSuspension.Name = "SpringSuspension"
  184. springSuspension.Attachment0 = springFrameAttachment
  185. springSuspension.Attachment1 = wheelAttachment
  186. springSuspension.LimitsEnabled = true
  187. springSuspension.MaxLength = suspensionMaxLength
  188. springSuspension.MinLength = suspensionMinLength
  189. springSuspension.Damping = suspensionDamping
  190. springSuspension.MaxForce = suspensionForce
  191. springSuspension.Stiffness = suspensionStiffness
  192. springSuspension.FreeLength = suspensionFreeLength
  193. weldTogether(base,frame,frame)
  194. frame.Anchored = false
  195. lever.Anchored = false
  196. wheel.Anchored = false
  197. elseif subject.Name == "FrontTurnSuspension" or subject.Name == "BackTurnSuspension" then
  198. local pivot = subject:FindFirstChild("Pivot")
  199. local frame = subject:FindFirstChild("Frame")
  200. local lever = subject:FindFirstChild("Lever")
  201. local wheel = subject:FindFirstChild("Wheel")
  202. -- Base to Pivot - Turning weld
  203. local turnWeld = weldTogether(base,pivot,subject.Parent)
  204. if subject.Name == "FrontTurn" then
  205. turnWeld.Name = "FrontTurnWeld"
  206. else
  207. turnWeld.Name = "BackTurnWeld"
  208. end
  209. -- Remember the original position
  210. local original = Instance.new("CFrameValue",turnWeld)
  211. original.Name = "Original"
  212. original.Value = turnWeld.C0
  213. -- Pivot to Frame - Axis of Rotation to Frame
  214. weldTogether(pivot,frame,frame)
  215. -- Frame to Lever - Torsion Bar Suspension Movement
  216. local pivotLeverAttachment = Instance.new("Attachment", lever)
  217. pivotLeverAttachment.Name = "PivotLeverAttachment"
  218. pivotLeverAttachment.Position = Vector3.new(0,1.25,-1.25)
  219. local pivotFrameAttachment = Instance.new("Attachment",frame)
  220. pivotFrameAttachment.Name = "PivotFrameAttachment"
  221. pivotFrameAttachment.Position = Vector3.new(0,0.25,-1.25)
  222. local suspensionPivot = Instance.new("HingeConstraint", frame)
  223. suspensionPivot.Name = "SuspensionPivot"
  224. suspensionPivot.Attachment0 = pivotFrameAttachment
  225. suspensionPivot.Attachment1 = pivotLeverAttachment
  226. suspensionPivot.LimitsEnabled = true
  227. suspensionPivot.LowerAngle = suspensionLowAngle
  228. suspensionPivot.UpperAngle = suspensionHighAngle
  229. -- Lever to Wheel for Wheel Rotation
  230. local wheelAttachment = Instance.new("Attachment", wheel)
  231. wheelAttachment.Name = "WheelAttachment"
  232. wheelAttachment.Position = Vector3.new(0,0,0)
  233. local axleLeverAttachment = Instance.new("Attachment", lever)
  234. axleLeverAttachment.Name = "AxleLeverAttachment"
  235. axleLeverAttachment.Position = Vector3.new(0,-1.25,1.25)
  236. local wheelMotor = Instance.new("HingeConstraint", subject.Parent)
  237. wheelMotor.Name = "WheelMotor"
  238. wheelMotor.ActuatorType = "Motor"
  239. wheelMotor.Attachment0 = axleLeverAttachment
  240. wheelMotor.Attachment1 = wheelAttachment
  241. wheelMotor.AngularVelocity = 0
  242. wheelMotor.MotorMaxTorque = torque
  243. wheelMotor.MotorMaxAcceleration = maxAcceleration
  244. -- Spring Suspension
  245. local springFrameAttachment = Instance.new("Attachment", frame)
  246. springFrameAttachment.Name = "SpringFrameAttachment"
  247. springFrameAttachment.Position = Vector3.new(0,0.25,1.25)
  248. local springSuspension = Instance.new("SpringConstraint",frame)
  249. springSuspension.Name = "SpringSuspension"
  250. springSuspension.Attachment0 = springFrameAttachment
  251. springSuspension.Attachment1 = wheelAttachment
  252. springSuspension.LimitsEnabled = true
  253. springSuspension.MaxLength = suspensionMaxLength
  254. springSuspension.MinLength = suspensionMinLength
  255. springSuspension.Damping = suspensionDamping
  256. springSuspension.MaxForce = suspensionForce
  257. springSuspension.Stiffness = suspensionStiffness
  258. springSuspension.FreeLength = suspensionFreeLength
  259. pivot.Anchored = false
  260. frame.Anchored = false
  261. lever.Anchored = false
  262. wheel.Anchored = false
  263. end
  264. end
  265.  
  266.  
  267.  
  268. -- Weld the Body to the Base
  269. for i = 1, #bodyParts do
  270. if bodyParts[i]:IsA("BasePart") or bodyParts[i].ClassName == "UnionOperation" then
  271. weldTogether(base,bodyParts[i],bodyParts[i])
  272. end
  273. end
  274.  
  275. -- Weld the Turret to the TurretAxle
  276. for i = 1, #turretParts do
  277. if turretParts[i]:IsA("BasePart") or turretParts[i].ClassName == "UnionOperation" then
  278. weldTogether(turretAxle, turretParts[i],turretParts[i])
  279. end
  280. end
  281.  
  282. -- Weld the Barrel to the BarrelAxle
  283. for i = 1, #barrelParts do
  284. if barrelParts[i]:IsA("BasePart") or barrelParts[i].ClassName == "UnionOperation" then
  285. weldTogether(barrelAxle, barrelParts[i],barrelParts[i])
  286. end
  287. end
  288.  
  289.  
  290. local traversalWeld = weldTogether(base, turretAxle, vehicle)
  291. traversalWeld.Name = "TraversalWeld"
  292.  
  293. local elevationWeld = weldTogether(turretAxle, barrelAxle, vehicle)
  294. elevationWeld.Name = "ElevationWeld"
  295.  
  296. weldTogether(base,vehicleSeat,vehicleSeat)
  297. weldTogether(base,rightThrust,rightThrust)
  298. weldTogether(base,leftThrust,leftThrust)
  299.  
  300. turretAxle.Anchored = false
  301. barrelAxle.Anchored = false
  302. base.Anchored = false
  303.  
  304.  
  305. function setLeftVelocity(velocity)
  306. local leftCh = vehicle:WaitForChild("LeftWheels"):GetChildren()
  307. for i = 1, #leftCh do
  308. if leftCh[i].Name == "WheelMotor" then
  309. leftCh[i].AngularVelocity = velocity
  310. end
  311. end
  312. end
  313.  
  314. function setRightVelocity(velocity)
  315. local rightCh = vehicle:WaitForChild("RightWheels"):GetChildren()
  316. for i = 1, #rightCh do
  317. if rightCh[i].Name == "WheelMotor" then
  318. rightCh[i].AngularVelocity = velocity
  319. end
  320. end
  321. end
  322.  
  323. function openHatch()
  324. local body = vehicle:FindFirstChild("Body"):GetChildren()
  325. local turret = vehicle:FindFirstChild("Turret"):GetChildren()
  326. for i = 1, #body do
  327. if body[i].Name == "Hatch" then
  328. body[i].CanCollide = false
  329. body[i].Transparency = 0.5
  330. end
  331. end
  332. for i = 1, #turret do
  333. if turret[i].Name == "Hatch" then
  334. turret[i].CanCollide = false
  335. turret[i].Transparency = 0.5
  336. end
  337. end
  338. end
  339.  
  340. function closeHatch()
  341. local body = vehicle:FindFirstChild("Body"):GetChildren()
  342. local turret = vehicle:FindFirstChild("Turret"):GetChildren()
  343. for i = 1, #body do
  344. if body[i].Name == "Hatch" then
  345. body[i].CanCollide = true
  346. body[i].Transparency = 0
  347. end
  348. end
  349. for i = 1, #turret do
  350. if turret[i].Name == "Hatch" then
  351. turret[i].CanCollide = true
  352. turret[i].Transparency = 0
  353. end
  354. end
  355. end
  356.  
  357. -- Raycast check for turret rotation
  358. function rayCast(start,finish)
  359. local aimVector=(finish-start).unit
  360. local hitPart, hitPos = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(start,aimVector*20), {game.Workspace, vehicle},false)
  361. return hitPos
  362. end
  363.  
  364. -- The steering controls
  365. vehicleSeat.Changed:connect(function(p)
  366. local leftVelocity = 0
  367. local rightVelocity = 0
  368. -- Swimming
  369. local leftSwim = 0
  370. local rightSwim = 0
  371. if rightThrust.Position.Y < -3.4 or leftThrust.Position.Y < -3.4 then
  372. -- Turning Right
  373. if vehicleSeat.Steer < 0 then
  374. leftSwim = leftSwim + boatForce/4
  375. rightSwim = rightSwim - boatForce/4
  376. -- Turning left
  377. elseif vehicleSeat.Steer > 0 then
  378. leftSwim = leftSwim - boatForce/4
  379. rightSwim = rightSwim + boatForce/4
  380. end
  381. -- Forward
  382. if vehicleSeat.Throttle > 0 then
  383. leftSwim = leftSwim - 3 * boatForce/4
  384. rightSwim = rightSwim - 3 * boatForce/4
  385. -- Backward
  386. elseif vehicleSeat.Throttle < 0 then
  387. leftSwim = leftSwim + 3*boatForce/4
  388. rightSwim = rightSwim + 3*boatForce/4
  389. end
  390. leftBodyThrust.Force = Vector3.new(0, 0, leftSwim)
  391. rightBodyThrust.Force = Vector3.new(0, 0, rightSwim)
  392. else
  393. leftBodyThrust.Force = Vector3.new(0, 0, 0)
  394. rightBodyThrust.Force = Vector3.new(0, 0, 0)
  395. end
  396.  
  397. -- Stationary Turning
  398. if vehicleSeat.Throttle == 0 then
  399. -- Turning right
  400. if vehicleSeat.Steer < 0 then
  401. leftVelocity = maxVelocity/stationaryTurnSharpness
  402. rightVelocity = - maxVelocity/stationaryTurnSharpness
  403. -- Turning left
  404. elseif vehicleSeat.Steer > 0 then
  405. leftVelocity = - maxVelocity/stationaryTurnSharpness
  406. rightVelocity = maxVelocity/stationaryTurnSharpness
  407. end
  408. -- Forward
  409. elseif vehicleSeat.Throttle > 0 then
  410. rightVelocity = - maxVelocity
  411. leftVelocity = - maxVelocity
  412. -- Turning right
  413. if vehicleSeat.Steer < 0 then
  414. leftVelocity = leftVelocity / turnSharpness
  415. -- Turning left
  416. elseif vehicleSeat.Steer > 0 then
  417. rightVelocity = rightVelocity / turnSharpness
  418. end
  419. -- Backward
  420. elseif vehicleSeat.Throttle < 0 then
  421. rightVelocity = maxVelocity
  422. leftVelocity = maxVelocity
  423. -- Turning right
  424. if vehicleSeat.Steer > 0 then
  425. rightVelocity = rightVelocity / turnSharpness
  426. -- Turning left
  427. elseif vehicleSeat.Steer < 0 then
  428. leftVelocity = leftVelocity / turnSharpness
  429. end
  430. end
  431. setLeftVelocity(leftVelocity)
  432. setRightVelocity(rightVelocity)
  433. end)
  434.  
  435. -- Tool Giver
  436. vehicleSeat.ChildAdded:connect(function(child)
  437. if child.Name == "SeatWeld" then
  438. if child.Part1.Name == "HumanoidRootPart" then
  439. local player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
  440. if player ~= nil then
  441. local tool = game.ReplicatedStorage[vehicleName]:Clone()
  442. tool:WaitForChild("TankReference").Value = vehicle
  443. tool.Parent = player.Backpack
  444. tool.ToolScript.Disabled = false
  445. vehicleSeat:SetNetworkOwner(player)
  446. base:SetNetworkOwner(player)
  447. closeHatch()
  448. engineSound.Volume = .1
  449. engineSound:Play()
  450. end
  451. end
  452. end
  453. end)
  454.  
  455. -- Player removed from seat
  456. vehicleSeat.ChildRemoved:connect(function(child)
  457. if child.Name == "SeatWeld" then
  458. setLeftVelocity(0)
  459. setRightVelocity(0)
  460. aim.Value = false
  461. openHatch()
  462. engineSound:Stop()
  463. end
  464. end)
  465.  
  466. local traversalWeld = vehicle:WaitForChild("TraversalWeld")
  467. local elevationWeld = vehicle:WaitForChild("ElevationWeld")
  468.  
  469. -- Turret Control
  470. aim.Changed:Connect(function(newValue)
  471. if aim.Value then
  472. turn:Play()
  473. end
  474. while aim.Value do
  475. -- Raycasting
  476. local mousePos = target.Value
  477. local hitPos = rayCast(barrelBreach.Position, barrelTip.Position)
  478. local mouseHitPos = rayCast(barrelBreach.Position, mousePos)
  479. -- Traversal Calculation
  480. local traversalAngle = ((- math.atan2((hitPos.z - base.Position.z ) , (hitPos.x - base.Position.x)) * 57.2958)) % 360
  481. local mouseAngle = ((- math.atan2((mousePos.z - base.Position.z ) , (mousePos.x - base.Position.x)) * 57.2958)) % 360
  482. local angleDif = (mouseAngle - traversalAngle) % 360
  483. if (angleDif < (359 - traversalSpeed/smoothness) and angleDif > traversalSpeed/smoothness) then
  484. if angleDif > 180 then
  485. traversalWeld.C0 = traversalWeld.C0 * CFrame.Angles(0,-math.rad(traversalSpeed/smoothness),0)
  486. elseif angleDif < 180 then
  487. traversalWeld.C0 = traversalWeld.C0 * CFrame.Angles(0,math.rad(traversalSpeed/smoothness),0)
  488. end
  489. else
  490. traversalWeld.C0 = traversalWeld.C0 * CFrame.Angles(0,math.rad(angleDif),0)
  491. end
  492.  
  493. -- Elevation Calculation
  494. local distDif = mouseHitPos.y - hitPos.y
  495. local barrelElevation = barrelAxle.Orientation.x - base.Orientation.x
  496. local changeAngle = math.acos((200-(distDif*distDif))/200)
  497. if ( changeAngle > (elevationSpeed/smoothness) ) then
  498. -- Aim Up
  499. if distDif > 0 and barrelElevation < maxElevation then
  500. elevationWeld.C0 = elevationWeld.C0 * CFrame.Angles(0,-math.rad((elevationSpeed/smoothness)),0)
  501. -- Aim Down
  502. elseif distDif < 0 and barrelElevation > minElevation then
  503. elevationWeld.C0 = elevationWeld.C0 * CFrame.Angles(0,math.rad((elevationSpeed/smoothness)),0)
  504. end
  505. else
  506. -- Aim Up
  507. if distDif > 0 and barrelElevation < maxElevation then
  508. elevationWeld.C0 = elevationWeld.C0 * CFrame.Angles(0,-math.rad(changeAngle),0)
  509. -- Aim Down
  510. elseif distDif < 0 and barrelElevation > minElevation then
  511. elevationWeld.C0 = elevationWeld.C0 * CFrame.Angles(0,math.rad(changeAngle),0)
  512. end
  513. end
  514. wait(1.0/smoothness)
  515. end
  516. turn:Stop()
  517. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement