Advertisement
nicholasXPG

Untitled

Oct 12th, 2016
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.83 KB | None | 0 0
  1. --[[
  2. Vehicle Support v8
  3. Variables:
  4.  
  5. Health
  6. MaxHealth
  7. ToughnessMinorDamage
  8. ToughnessMajorDamage
  9.  
  10. DriftAcceleration
  11. DriftSteerDifficulty
  12. DriftSteerPower
  13.  
  14. Acceleration
  15. TopSpeed
  16. Deceleration
  17. BrakePower
  18.  
  19. SteerDifficulty
  20. SteerPower
  21.  
  22. TireFriction
  23. TireElasticity
  24. MasterColor
  25. Wrecked
  26.  
  27. Vehicle (Model)
  28. Base (Part)
  29. Thrust (BodyVelocity)
  30. Steer (BodyGyro)
  31. Seat (VehicleSeat)
  32. --]]
  33.  
  34.  
  35. Wheels = {}
  36. RearTraction = false
  37. FrontTraction = false
  38.  
  39. DriftCheck = 0
  40. Drifting = false
  41.  
  42. ThrottlePercent = 0
  43. IsBraking = false
  44.  
  45. SteerPercent = 0
  46.  
  47. if Wrecked == true then Health = math.random(1, MaxHealth) end
  48.  
  49. for _, Part in pairs(Vehicle:GetChildren()) do
  50. if Part:IsA("BasePart") then
  51. Part.Locked = true
  52. if Wrecked == true then
  53. pcall(function() Part.Weld.C1 = Part.Weld.C1 * CFrame.fromEulerAnglesXYZ(math.rad(math.random(-7.5, 7.5)), math.rad(math.random(-7.5, 7.5)), math.rad(math.random(-7.5, 7.5))) end)
  54. if math.random(1, 5) == 1 then Part.Material = "CorrodedMetal" end
  55. if math.random(1, 10) == 1 then Part.BrickColor = BrickColor.new("Black") end
  56. if math.random(1, 50) == 1 then Part.BrickColor = BrickColor.new("Really black") end
  57. end
  58. if string.match(Part.Name, "VehicleSeat") == nil and string.match(Part.Name, "VehicleEngine") == nil and string.match(Part.Name, "VehicleBase") == nil and string.match(Part.Name, " Wheel") == nil then
  59. Part.Touched:connect(function(Hit)
  60. if Hit.Parent == nil then return end
  61. if Hit.Parent == Vehicle then return end
  62. if Hit.CanCollide == false then return end
  63. if Part:FindFirstChild("Weld") == nil then return end
  64. if string.match(Hit.Name, "VehicleSeat") or string.match(Hit.Name, "VehicleEngine") or string.match(Hit.Name, "VehicleBase") then return end
  65. local velocity1 = {
  66. math.abs(Part.Velocity.x),
  67. math.abs(Part.Velocity.y),
  68. math.abs(Part.Velocity.z)
  69. }
  70. local rotvelocity1 = {
  71. math.abs(Part.RotVelocity.x),
  72. math.abs(Part.RotVelocity.y),
  73. math.abs(Part.RotVelocity.z)
  74. }
  75. local velocity2 = {
  76. math.abs(Hit.Velocity.x),
  77. math.abs(Hit.Velocity.y),
  78. math.abs(Hit.Velocity.z)
  79. }
  80. local rotvelocity2 = {
  81. math.abs(Hit.RotVelocity.x),
  82. math.abs(Hit.RotVelocity.y),
  83. math.abs(Hit.RotVelocity.z)
  84. }
  85. for i = 1, #velocity1 do
  86. local Total = math.abs(velocity1[i] - velocity2[i])
  87. if Total > ToughnessMinorDamage / 2 then
  88. Health = Health - (Total / 10)
  89. end
  90. if Total > ToughnessMinorDamage then
  91. ThrottlePercent = ThrottlePercent * 0.9
  92. pcall(function() Part.Weld.C0 = Part.Weld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(math.random(-Total / 10, Total / 10)), math.rad(math.random(-Total / 10, Total / 10)), math.rad(math.random(-Total / 10, Total / 10))) end)
  93. pcall(function() Part.Weld.C1 = Part.Weld.C1 * CFrame.fromEulerAnglesXYZ(math.rad(math.random(-Total / 10, Total / 10)), math.rad(math.random(-Total / 10, Total / 10)), math.rad(math.random(-Total / 10, Total / 10))) end)
  94. end
  95. if Total > ToughnessMajorDamage and Hit:GetMass() > 3 then
  96. ThrottlePercent = 0
  97. Part:BreakJoints()
  98. Part.Velocity = Part.Velocity + math.random(math.random(-Total / 10, Total / 10), math.random(-Total / 10, Total / 10), math.random(-Total / 10, Total / 10))
  99. Part.RotVelocity = Part.RotVelocity + math.random(math.random(-Total / 25, Total / 25), math.random(-Total / 25, Total / 25), math.random(-Total / 25, Total / 25))
  100. end
  101. if Total > math.random(50, 75) then
  102. if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
  103. local Tag = Instance.new("ObjectValue", Hit.Parent.Humanoid)
  104. Tag.Name = "creator"
  105. Tag.Value = Driver
  106. coroutine.wrap(function() wait(1) Tag:Remove() end)()
  107. end
  108. Hit:BreakJoints()
  109. end
  110. end
  111. for i = 1, #rotvelocity1 do
  112. local Total = math.abs(velocity1[i] - velocity2[i])
  113. if Total > ToughnessMinorDamage / 4 and not string.match(Part.Name, " Wheel") then
  114. Health = Health - (Total / 10)
  115. end
  116. if Total > ToughnessMinorDamage / 2 and not string.match(Part.Name, " Wheel") then
  117. ThrottlePercent = ThrottlePercent * 0.9
  118. pcall(function() Part.Weld.C0 = Part.Weld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(math.random(-Total / 10, Total / 10)), math.rad(math.random(-Total / 10, Total / 10)), math.rad(math.random(-Total / 10, Total / 10))) end)
  119. pcall(function() Part.Weld.C1 = Part.Weld.C1 * CFrame.fromEulerAnglesXYZ(math.rad(math.random(-Total / 10, Total / 10)), math.rad(math.random(-Total / 10, Total / 10)), math.rad(math.random(-Total / 10, Total / 10))) end)
  120. end
  121. if Total > ToughnessMajorDamage / 2 and Hit:GetMass() > 3 then
  122. ThrottlePercent = ThrottlePercent * 0.75
  123. Part:BreakJoints()
  124. Part.Velocity = Part.Velocity + Vector3.new(math.random(-Total / 10, Total / 10), math.random(-Total / 10, Total / 10), math.random(-Total / 10, Total / 10))
  125. Part.RotVelocity = Part.RotVelocity + Vector3.new(math.random(-Total / 25, Total / 25), math.random(-Total / 25, Total / 25), math.random(-Total / 25, Total / 25))
  126. end
  127. if Total > math.random(50, 75) then
  128. if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
  129. local Tag = Instance.new("ObjectValue", Hit.Parent.Humanoid)
  130. Tag.Name = "creator"
  131. Tag.Value = Driver
  132. coroutine.wrap(function() wait(1) Tag:Remove() end)()
  133. end
  134. Hit:BreakJoints()
  135. end
  136. end
  137. end)
  138. end
  139. if string.match(Part.Name, " Wheel") then
  140. table.insert(Wheels, Part)
  141. end
  142. Part.ChildRemoved:connect(function(Object)
  143. if Object.Name == "Weld" then
  144. Health = Health - 25
  145. end
  146. end)
  147. end
  148. end
  149.  
  150.  
  151. while true do
  152. RearTraction = false
  153. FrontTraction = false
  154. for _, Part in pairs(Wheels) do
  155. local Hit = Workspace:FindPartOnRay(Ray.new(Part.Position, (Part.Position - (Part.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(90)) * CFrame.new(0, -1, 0)).p).unit * ((Part.Size.x / 2) + 0.5)), Vehicle)
  156. if Hit ~= nil and Part:FindFirstChild("Weld") ~= nil then
  157. if string.match(Part.Name, "Rear") then
  158. RearTraction = true
  159. else
  160. FrontTraction = true
  161. end
  162. end
  163. end
  164. if Vehicle:FindFirstChild("VehicleEngine") ~= nil then
  165. if Vehicle.VehicleEngine:FindFirstChild("Weld") == nil then
  166. Health = 0
  167. end
  168. if pcall(function() return EffectHolder.Parent end) == false then
  169. EffectHolder = Instance.new("Part")
  170. EffectHolder.Name = ""
  171. EffectHolder.CanCollide = false
  172. EffectHolder.Anchored = true
  173. EffectHolder.FormFactor = "Custom"
  174. EffectHolder.Size = Vector3.new(1, 1, 1)
  175. EffectHolder.TopSurface = 0
  176. EffectHolder.BottomSurface = 0
  177. EffectHolder.Transparency = 1
  178. EffectHolder.Parent = Vehicle
  179. end
  180. EffectHolder.CFrame = CFrame.new(Vehicle.VehicleEngine.Position)
  181. for _, Part in pairs(EffectHolder:GetChildren()) do
  182. pcall(function() Part.Enabled = false end)
  183. end
  184. if Health <= 0 then
  185. if EffectHolder:FindFirstChild("Smoke 0") == nil then
  186. local Smoke = Instance.new("Smoke")
  187. Smoke.Name = "Smoke 0"
  188. Smoke.Color = Color3.new(0.05, 0.05, 0.05)
  189. Smoke.RiseVelocity = 12.5
  190. Smoke.Size = 12.5
  191. Smoke.Parent = EffectHolder
  192. end
  193. if EffectHolder:FindFirstChild("Fire 0") == nil then
  194. local Fire = Instance.new("Fire")
  195. Fire.Name = "Fire 0"
  196. Fire.Heat = 10
  197. Fire.Size = 20
  198. Fire.Parent = EffectHolder
  199. end
  200. EffectHolder["Smoke 0"].Enabled = true
  201. EffectHolder["Fire 0"].Enabled = true
  202. elseif Health < MaxHealth * 0.15 then
  203. if EffectHolder:FindFirstChild("Smoke 1") == nil then
  204. local Smoke = Instance.new("Smoke")
  205. Smoke.Name = "Smoke 1"
  206. Smoke.Color = Color3.new(0.25, 0.25, 0.25)
  207. Smoke.RiseVelocity = 10
  208. Smoke.Size = 10
  209. Smoke.Parent = EffectHolder
  210. end
  211. if EffectHolder:FindFirstChild("Fire 1") == nil then
  212. local Fire = Instance.new("Fire")
  213. Fire.Name = "Fire 1"
  214. Fire.Heat = 5
  215. Fire.Size = 10
  216. Fire.Parent = EffectHolder
  217. end
  218. EffectHolder["Smoke 1"].Enabled = true
  219. EffectHolder["Fire 1"].Enabled = true
  220. elseif Health < MaxHealth * 0.2 then
  221. if EffectHolder:FindFirstChild("Smoke 2") == nil then
  222. local Smoke = Instance.new("Smoke")
  223. Smoke.Name = "Smoke 2"
  224. Smoke.Color = Color3.new(0.5, 0.5, 0.5)
  225. Smoke.RiseVelocity = 9
  226. Smoke.Size = 7.5
  227. Smoke.Parent = EffectHolder
  228. end
  229. EffectHolder["Smoke 2"].Enabled = true
  230. elseif Health < MaxHealth * 0.3 then
  231. if EffectHolder:FindFirstChild("Smoke 3") == nil then
  232. local Smoke = Instance.new("Smoke")
  233. Smoke.Name = "Smoke 3"
  234. Smoke.Color = Color3.new(0.75, 0.75, 0.75)
  235. Smoke.RiseVelocity = 7.5
  236. Smoke.Size = 5
  237. Smoke.Parent = EffectHolder
  238. end
  239. EffectHolder["Smoke 3"].Enabled = true
  240. elseif Health < MaxHealth * 0.4 then
  241. if EffectHolder:FindFirstChild("Smoke 4") == nil then
  242. local Smoke = Instance.new("Smoke")
  243. Smoke.Name = "Smoke 4"
  244. Smoke.Color = Color3.new(1, 1, 1)
  245. Smoke.RiseVelocity = 5
  246. Smoke.Size = 3
  247. Smoke.Parent = EffectHolder
  248. end
  249. EffectHolder["Smoke 4"].Enabled = true
  250. end
  251. else
  252. Health = 0
  253. if EffectHolder ~= nil then
  254. EffectHolder:Remove()
  255. EffectHolder = nil
  256. end
  257. end
  258. if ThrottlePercent < 0.2 then
  259. Drifting = false
  260. DriftCheck = 0
  261. end
  262. if Seat.Throttle == 1 then
  263. if ThrottlePercent > 0.2 and tick() - DriftCheck < 0.5 and Drifting == false then
  264. coroutine.wrap(function()
  265. DriftCheck = 0
  266. Drifting = true
  267. local OldAcceleration = Acceleration
  268. local OldSteerDifficulty = SteerDifficulty
  269. local OldSteerPower = SteerPower
  270. Acceleration = DriftAcceleration
  271. SteerDifficulty = DriftSteerDifficulty
  272. SteerPower = DriftSteerPower
  273. local EffectHolder1 = Instance.new("Part")
  274. EffectHolder1.Name = ""
  275. EffectHolder1.CanCollide = false
  276. EffectHolder1.Anchored = true
  277. EffectHolder1.FormFactor = "Custom"
  278. EffectHolder1.Size = Vector3.new(1, 1, 1)
  279. EffectHolder1.TopSurface = 0
  280. EffectHolder1.BottomSurface = 0
  281. EffectHolder1.Transparency = 1
  282. EffectHolder1.Parent = Vehicle
  283. local Smoke = Instance.new("Smoke")
  284. Smoke.Color = Color3.new(0.9, 0.9, 0.9)
  285. Smoke.RiseVelocity = 15
  286. Smoke.Size = 10
  287. Smoke.Parent = EffectHolder1
  288. local EffectHolder2 = Instance.new("Part")
  289. EffectHolder2.Name = ""
  290. EffectHolder2.CanCollide = false
  291. EffectHolder2.Anchored = true
  292. EffectHolder2.FormFactor = "Custom"
  293. EffectHolder2.Size = Vector3.new(1, 1, 1)
  294. EffectHolder2.TopSurface = 0
  295. EffectHolder2.BottomSurface = 0
  296. EffectHolder2.Transparency = 1
  297. EffectHolder2.Parent = Vehicle
  298. local Smoke = Instance.new("Smoke")
  299. Smoke.Color = Color3.new(0.9, 0.9, 0.9)
  300. Smoke.RiseVelocity = 15
  301. Smoke.Size = 10
  302. Smoke.Parent = EffectHolder2
  303. while Drifting == true do
  304. if pcall(function() return Vehicle["Rear Left Wheel"].Weld end) == true then
  305. EffectHolder1.CFrame = Vehicle["Rear Left Wheel"].CFrame * CFrame.fromEulerAnglesXYZ(math.rad(-90), 0, 0)
  306. else
  307. EffectHolder1.Smoke.Enabled = false
  308. end
  309. if pcall(function() return Vehicle["Rear Right Wheel"].Weld end) == true then
  310. EffectHolder2.CFrame = Vehicle["Rear Right Wheel"].CFrame * CFrame.fromEulerAnglesXYZ(math.rad(-90), 0, 0)
  311. else
  312. EffectHolder2.Smoke.Enabled = false
  313. end
  314. wait()
  315. end
  316. Acceleration = OldAcceleration
  317. SteerDifficulty = OldSteerDifficulty
  318. SteerPower = OldSteerPower
  319. EffectHolder1.Smoke.Enabled = false
  320. EffectHolder2.Smoke.Enabled = false
  321. wait(7.5)
  322. EffectHolder1:Remove()
  323. EffectHolder2:Remove()
  324. end)()
  325. coroutine.wrap(function()
  326. while Drifting == true do
  327. if pcall(function() return Vehicle["Rear Left Wheel"].Weld end) == true then
  328. local DriftSound = Instance.new("Sound")
  329. DriftSound.SoundId = "http://www.roblox.com/Asset/?id=31245495"
  330. DriftSound.Volume = 1
  331. DriftSound.Pitch = math.random(90, 120) / 100
  332. DriftSound.Parent = Vehicle["Rear Left Wheel"]
  333. DriftSound:Play()
  334. end
  335. wait(math.random(35, 60) / 100)
  336. end
  337. end)()
  338. coroutine.wrap(function()
  339. while Drifting == true do
  340. if pcall(function() return Vehicle["Rear Right Wheel"].Weld end) == true then
  341. local DriftSound = Instance.new("Sound")
  342. DriftSound.SoundId = "http://www.roblox.com/Asset/?id=31245495"
  343. DriftSound.Volume = 1
  344. DriftSound.Pitch = math.random(90, 120) / 100
  345. DriftSound.Parent = Vehicle["Rear Right Wheel"]
  346. DriftSound:Play()
  347. end
  348. wait(math.random(35, 60) / 100)
  349. end
  350. end)()
  351. coroutine.wrap(function()
  352. while Drifting == true do
  353. if pcall(function() return Vehicle["Rear Wheel"].Weld end) == true then
  354. local DriftSound = Instance.new("Sound")
  355. DriftSound.SoundId = "http://www.roblox.com/Asset/?id=31245495"
  356. DriftSound.Volume = 1
  357. DriftSound.Pitch = math.random(90, 120) / 100
  358. DriftSound.Parent = Vehicle["Rear Wheel"]
  359. DriftSound:Play()
  360. end
  361. wait(math.random(35, 60) / 100)
  362. end
  363. end)()
  364. end
  365. if ThrottlePercent < 0 then
  366. ThrottlePercent = ThrottlePercent + BrakePower
  367. IsBraking = true
  368. else
  369. ThrottlePercent = ThrottlePercent + Acceleration
  370. IsBraking = false
  371. end
  372. elseif Seat.Throttle == -1 then
  373. Drifting = false
  374. if ThrottlePercent > 0.1 then
  375. ThrottlePercent = ThrottlePercent - BrakePower
  376. IsBraking = true
  377. DriftCheck = tick()
  378. else
  379. ThrottlePercent = ThrottlePercent - Acceleration
  380. end
  381. else
  382. if ThrottlePercent < 0 then
  383. ThrottlePercent = ThrottlePercent + Deceleration
  384. elseif ThrottlePercent > 0 then
  385. ThrottlePercent = ThrottlePercent - Deceleration
  386. end
  387. if ThrottlePercent > -Deceleration * 1.1 and ThrottlePercent < Deceleration * 1.1 then
  388. ThrottlePercent = 0
  389. end
  390. end
  391. if ThrottlePercent > 1 then ThrottlePercent = 1 end
  392. if ThrottlePercent < -1 then ThrottlePercent = -1 end
  393. if ThrottlePercent ~= 0 and RearTraction == true and (pcall(function() return Vehicle["Rear Left Wheel"].Weld end) == true or pcall(function() return Vehicle["Rear Right Wheel"].Weld end) == true or pcall(function() return Vehicle["Rear Wheel"].Weld end) == true) and Health > 0 then
  394. Thrust.maxForce = Vector3.new(math.huge, 0, math.huge)
  395. Thrust.velocity = Base.CFrame.lookVector * (TopSpeed * ThrottlePercent)
  396. else
  397. Thrust.maxForce = Vector3.new()
  398. end
  399. if Seat.Steer == 1 then
  400. SteerPercent = SteerPercent - (SteerDifficulty * (1 - (math.abs(ThrottlePercent) / 10)))
  401. elseif Seat.Steer == -1 then
  402. SteerPercent = SteerPercent + (SteerDifficulty * (1 - (math.abs(ThrottlePercent) / 10)))
  403. else
  404. if SteerPercent < 0 then
  405. SteerPercent = SteerPercent + SteerDifficulty
  406. elseif SteerPercent > 0 then
  407. SteerPercent = SteerPercent - SteerDifficulty
  408. end
  409. if SteerPercent > -SteerDifficulty * 1.1 and SteerPercent < SteerDifficulty * 1.1 then
  410. SteerPercent = 0
  411. Drifting = false
  412. end
  413. end
  414. if SteerPercent > 1 then SteerPercent = 1 end
  415. if SteerPercent < -1 then SteerPercent = -1 end
  416. if SteerPercent ~= 0 and RearTraction == true and FrontTraction == true and (pcall(function() return Vehicle["Rear Left Wheel"].Weld end) == true or pcall(function() return Vehicle["Rear Right Wheel"].Weld end) == true) and (pcall(function() return Vehicle["Front Left Wheel"].Weld end) == true or pcall(function() return Vehicle["Front Right Wheel"].Weld end) == true) and Health > 0 then
  417. Steer.maxTorque = Vector3.new(0, math.huge, 0)
  418. Steer.cframe = (Base.CFrame - Base.Position) * CFrame.fromEulerAnglesXYZ(0, math.rad((SteerPercent * SteerPower) * ((ThrottlePercent * 10) > 1 and 1 or (ThrottlePercent * 10))), 0)
  419. ThrottlePercent = ThrottlePercent - ((Acceleration * 0.95) * (1 - math.abs(SteerPercent)))
  420. ThrottlePercent = ThrottlePercent - (Acceleration * (SteerPercent / 2))
  421. else
  422. Steer.maxTorque = Vector3.new()
  423. Steer.cframe = CFrame.new()
  424. end
  425. local SteerAngle = SteerPercent * (SteerPower * 1.5)
  426. if SteerAngle > 80 then SteerAngle = 80 end
  427. if SteerAngle < -80 then SteerAngle = -80 end
  428. for _, Part in pairs(Wheels) do
  429. if string.match(Part.Name, "Front ") then
  430. pcall(function()
  431. Part.Weld.C0 = CFrame.new(Part.Weld.C0.p) * CFrame.fromEulerAnglesXYZ(0, math.rad(SteerAngle), math.rad(90))
  432. end)
  433. end
  434. end
  435. if Seat:FindFirstChild("SeatWeld") ~= nil and Driver == nil then
  436. local Part1 = Seat.SeatWeld.Part1
  437. if Part1 ~= nil then
  438. Driver = game:GetService("Players"):GetPlayerFromCharacter(Part1.Parent)
  439. if Driver ~= nil then
  440. local PlayerGui = Driver:FindFirstChild("PlayerGui")
  441. if PlayerGui == nil then return end
  442. local DriverGui = Instance.new("ScreenGui", PlayerGui)
  443. DriverGui.Name = "DriverGui"
  444. local Frame = Instance.new("Frame")
  445. Frame.Name = "Content"
  446. Frame.Size = UDim2.new(1, 0, 0, 100)
  447. Frame.Position = UDim2.new(0, 0, 1, -100)
  448. Frame.BorderSizePixel = 1
  449. Frame.BorderColor3 = Color3.new(0, 0, 0)
  450. Frame.BackgroundColor3 = Color3.new(0.15, 0.15, 0.15)
  451. Frame.Parent = DriverGui
  452. local TextLabel = Instance.new("TextLabel")
  453. TextLabel.Name = "SpeedText1"
  454. TextLabel.Size = UDim2.new(0, 85, 0, 15)
  455. TextLabel.Position = UDim2.new(0, 15, 0, 7.5)
  456. TextLabel.BorderSizePixel = 0
  457. TextLabel.BackgroundTransparency = 1
  458. TextLabel.TextColor3 = Color3.new(1, 1, 1)
  459. TextLabel.Text = "Speed"
  460. TextLabel.TextXAlignment = "Left"
  461. TextLabel.FontSize = "Size12"
  462. TextLabel.Parent = DriverGui.Content
  463. local TextLabel = Instance.new("TextLabel")
  464. TextLabel.Name = "SpeedText2"
  465. TextLabel.Size = UDim2.new(0, 85, 0, 15)
  466. TextLabel.Position = UDim2.new(0, 15, 0, 7.5 + 15)
  467. TextLabel.BorderSizePixel = 0
  468. TextLabel.BackgroundTransparency = 1
  469. TextLabel.TextColor3 = Color3.new(1, 1, 1)
  470. TextLabel.Text = "Bricks/sec."
  471. TextLabel.TextXAlignment = "Left"
  472. TextLabel.FontSize = "Size12"
  473. TextLabel.Parent = DriverGui.Content
  474. for i = 0, 1, 0.1 do
  475. local TextLabel = Instance.new("TextLabel")
  476. TextLabel.Name = "SpeedTextInc" ..i
  477. TextLabel.Size = UDim2.new(0, 0, 0, 15)
  478. TextLabel.Position = UDim2.new(0, 92 + (i * 200), 0, 37.5)
  479. TextLabel.BorderSizePixel = 1
  480. TextLabel.BackgroundTransparency = 0
  481. TextLabel.TextColor3 = Color3.new(1, 1, 1)
  482. TextLabel.Text = math.floor(TopSpeed * i)
  483. TextLabel.TextXAlignment = "Left"
  484. TextLabel.Parent = DriverGui.Content
  485. end
  486. local Frame = Instance.new("Frame")
  487. Frame.Name = "SpeedBack"
  488. Frame.Size = UDim2.new(0, 200, 0, 30)
  489. Frame.Position = UDim2.new(0, 100, 0, 7.5)
  490. Frame.BorderSizePixel = 1
  491. Frame.BorderColor3 = Color3.new(0, 0, 0)
  492. Frame.BackgroundColor3 = Color3.new(0, 0, 0)
  493. Frame.Parent = DriverGui.Content
  494. local Frame = Instance.new("Frame")
  495. Frame.Name = "SpeedFront"
  496. Frame.BorderSizePixel = 1
  497. Frame.BorderColor3 = Color3.new(0, 0, 0)
  498. Frame.BackgroundColor3 = Color3.new(0, 0, 0.9)
  499. Frame.Parent = DriverGui.Content
  500. coroutine.wrap(function()
  501. while DriverGui.Parent ~= nil do
  502. DriverGui.Content.SpeedFront.Size = DriverGui.Content.SpeedBack.Size - UDim2.new(0, DriverGui.Content.SpeedBack.Size.X.Offset * (1 - math.abs(ThrottlePercent)), 0, 0)
  503. DriverGui.Content.SpeedFront.Position = DriverGui.Content.SpeedBack.Position
  504. wait()
  505. end
  506. end)()
  507. local TextLabel = Instance.new("TextLabel")
  508. TextLabel.Name = "DamageText"
  509. TextLabel.Size = UDim2.new(0, 85, 0, 30)
  510. TextLabel.Position = UDim2.new(0, 215, 0, 57.5)
  511. TextLabel.BorderSizePixel = 0
  512. TextLabel.BackgroundTransparency = 1
  513. TextLabel.TextColor3 = Color3.new(1, 1, 1)
  514. TextLabel.Text = "Damage"
  515. TextLabel.TextXAlignment = "Left"
  516. TextLabel.FontSize = "Size12"
  517. TextLabel.Parent = DriverGui.Content
  518. local Frame = Instance.new("Frame")
  519. Frame.Name = "DamageBack"
  520. Frame.Size = UDim2.new(0, 250, 0, 30)
  521. Frame.Position = UDim2.new(0, 300, 0, 57.5)
  522. Frame.BorderSizePixel = 1
  523. Frame.BorderColor3 = Color3.new(0, 0, 0)
  524. Frame.BackgroundColor3 = Color3.new(0, 0.5, 0)
  525. Frame.Parent = DriverGui.Content
  526. local Frame = Instance.new("Frame")
  527. Frame.Name = "DamageFront"
  528. Frame.BorderSizePixel = 1
  529. Frame.BorderColor3 = Color3.new(0, 0, 0)
  530. Frame.BackgroundColor3 = Color3.new(0.9, 0, 0)
  531. Frame.Parent = DriverGui.Content
  532. coroutine.wrap(function()
  533. local i = math.pi * 1.5
  534. while DriverGui.Parent ~= nil do
  535. DriverGui.Content.DamageFront.Size = DriverGui.Content.DamageBack.Size - UDim2.new(0, DriverGui.Content.DamageBack.Size.X.Offset * (1 - ((MaxHealth - Health) / MaxHealth)), 0, 0)
  536. DriverGui.Content.DamageFront.Position = DriverGui.Content.DamageBack.Position
  537. if Health < MaxHealth * 0.15 then
  538. i = i + 0.4
  539. elseif Health < MaxHealth * 0.2 then
  540. i = i + 0.25
  541. elseif Health < MaxHealth * 0.3 then
  542. i = i + 0.1
  543. elseif Health < MaxHealth * 0.4 then
  544. i = i + 0.075
  545. end
  546. DriverGui.Content.DamageFront.BackgroundColor3 = Color3.new(1 - ((math.sin(i) + 1) / 2), 0, 0)
  547. DriverGui.Content.DamageBack.BackgroundColor3 = Color3.new(0, 0.5 - (((math.sin(i) + 1) / 2) * 0.5), 0)
  548. wait()
  549. end
  550. end)()
  551. end
  552. end
  553. elseif Seat:FindFirstChild("SeatWeld") == nil and Driver ~= nil then
  554. if Driver:FindFirstChild("PlayerGui") ~= nil then
  555. if Driver.PlayerGui:FindFirstChild("DriverGui") ~= nil then
  556. Driver.PlayerGui.DriverGui:Remove()
  557. end
  558. end
  559. Driver = nil
  560. end
  561. if Health <= 0 then
  562. Health = 0
  563. ThrottlePercent = 0
  564. if Vehicle:FindFirstChild("VehicleEngine") ~= nil then
  565. if math.random(1, 1000) == 1 or Vehicle.VehicleEngine:FindFirstChild("Weld") == nil then
  566. local Explosion = Instance.new("Explosion")
  567. Explosion.BlastPressure = 5000 * ToughnessMajorDamage
  568. Explosion.BlastRadius = ToughnessMajorDamage / 10
  569. Explosion.Position = Vehicle.VehicleEngine.Position
  570. Explosion.Parent = Workspace
  571. Vehicle.VehicleEngine.Name = "Exploded VehicleEngine"
  572. end
  573. end
  574. end
  575. wait()
  576. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement