Guest User

Roblox - Race Car Script

a guest
Jun 17th, 2018
21,521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.05 KB | None | 0 0
  1. -- This works in FE, tested via Roblox Studio's "Test" tab.
  2.  
  3. local speed = 92
  4. local equipped
  5. local plr = game:GetService("Players").LocalPlayer
  6. local plrchar = plr.Character or plr.CharacterAdded:Wait()
  7.  
  8. local tool = Instance.new("Tool", plr:WaitForChild("Backpack"))
  9. tool.Name = "RaceCar"
  10. local handle = Instance.new("Part", tool)
  11. handle.Name = "Handle"
  12. handle.CanCollide = true
  13. handle.Anchored = false
  14. local mesh = Instance.new("SpecialMesh", handle)
  15. mesh.MeshId = "http://www.roblox.com/asset/?id=264666411"
  16. mesh.TextureId = "http://www.roblox.com/asset/?id=264326115"
  17. mesh.Scale = Vector3.new(3, 3, 3)
  18.  
  19. local gui = Instance.new("ScreenGui", plr:WaitForChild("PlayerGui"))
  20. gui.Name = "RaceCarGUI"
  21. local frame = Instance.new("Frame", gui)
  22. frame.Size = UDim2.new(1, 0, .3, 0)
  23. frame.Position = UDim2.new(0, 0, .7, 0)
  24. frame.BackgroundTransparency = .5
  25. frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  26. frame.BorderSizePixel = 0
  27. local SetSpeed_label = Instance.new("TextLabel", frame)
  28. SetSpeed_label.Name = "SetSpeed_label"
  29. SetSpeed_label.BorderSizePixel = 0
  30. SetSpeed_label.Size = UDim2.new(1, 0, .25, 0)
  31. SetSpeed_label.Font = Enum.Font.Arcade
  32. SetSpeed_label.Text = "Set Speed"
  33. SetSpeed_label.TextSize = 30
  34. SetSpeed_label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  35. local SetSpeed = Instance.new("TextBox", frame)
  36. SetSpeed.BackgroundTransparency = 1
  37. SetSpeed.BorderSizePixel = 0
  38. SetSpeed.Position = UDim2.new(0, 0, .25, 0)
  39. SetSpeed.Size = UDim2.new(1, 0, .75, 0)
  40. SetSpeed.Font = Enum.Font.SourceSansLight
  41. SetSpeed.PlaceholderColor3 = Color3.fromRGB(48, 178, 96)
  42. SetSpeed.PlaceholderText = "Speed in studs"
  43. SetSpeed.Text = ""
  44. SetSpeed.TextScaled = true
  45.  
  46. local prevSpeed = plrchar:WaitForChild("Humanoid").WalkSpeed
  47. local prevJumpPower = plrchar:WaitForChild("Humanoid").JumpPower
  48.  
  49. tool.Equipped:Connect(function()
  50.     prevSpeed = plrchar:WaitForChild("Humanoid").WalkSpeed
  51.     prevJumpPower = plrchar:WaitForChild("Humanoid").JumpPower
  52.     -- In case the player has set another speed
  53.     plrchar:WaitForChild("Humanoid").WalkSpeed = speed
  54.     plrchar:WaitForChild("Humanoid").JumpPower = 1
  55.     equipped = true
  56. end)
  57.  
  58. tool.Unequipped:Connect(function()
  59.     plrchar:WaitForChild("Humanoid").WalkSpeed = prevSpeed
  60.     plrchar:WaitForChild("Humanoid").JumpPower = prevJumpPower
  61.     equipped = false
  62. end)
  63.  
  64. function SignalError()
  65.     SetSpeed_label.TextColor3 = Color3.fromRGB(232, 23, 23)
  66.     wait(3)
  67.     SetSpeed_label.TextColor3 = Color3.new(0, 0, 0)
  68. end
  69.  
  70. function SignalSuccess()
  71.     SetSpeed_label.TextColor3 = Color3.fromRGB(51, 204, 40)
  72.     wait(3)
  73.     SetSpeed_label.TextColor3 = Color3.new(0, 0, 0)
  74. end
  75.  
  76. SetSpeed.FocusLost:Connect(function(enter)
  77.     if enter == true then
  78.         if tonumber(SetSpeed.Text) ~= nil then
  79.             speed = tonumber(SetSpeed.Text)
  80.             if equipped == true then
  81.                 plrchar:WaitForChild("Humanoid").WalkSpeed = speed
  82.             end
  83.             SignalSuccess()
  84.             SetSpeed.Text = ""
  85.         else
  86.             SignalError()
  87.             SetSpeed.Text = ""
  88.         end
  89.     else
  90.         SetSpeed.Text = ""
  91.     end
  92. end)
  93.  
  94. plrchar:WaitForChild("Humanoid").Died:Connect(function()
  95.     gui:Destroy()
  96.     script:Destroy()
  97. end)
Advertisement
Add Comment
Please, Sign In to add comment