local player = game:GetService("Players").LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local rootPart = character:WaitForChild("HumanoidRootPart") local userInputService = game:GetService("UserInputService") local runService = game:GetService("RunService") local drivingSpeed = 50 local turningSpeed = 3 local acceleration = 0.8 local deceleration = 1.2 local friction = 0.5 local isDriving = false local originalWalkSpeed = 16 local originalJumpPower = 50 local carBase, bodyVelocity, bodyGyro, weld local currentSpeed = 0 local targetRotation = 0 local keysPressed = { W = false, A = false, S = false, D = false } local screenGui = Instance.new("ScreenGui") screenGui.Name = "DrivingGUI" screenGui.ResetOnSpawn = false screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling screenGui.Parent = player:WaitForChild("PlayerGui") local creditsFrame = Instance.new("Frame") creditsFrame.Size = UDim2.new(0, 280, 0, 80) creditsFrame.Position = UDim2.new(1, -300, 1, -100) creditsFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40) creditsFrame.BorderSizePixel = 2 creditsFrame.BorderColor3 = Color3.fromRGB(100, 200, 255) creditsFrame.ZIndex = 15 creditsFrame.Parent = screenGui local creditsCorner = Instance.new("UICorner") creditsCorner.CornerRadius = UDim.new(0, 10) creditsCorner.Parent = creditsFrame local creditsTitle = Instance.new("TextLabel") creditsTitle.Size = UDim2.new(1, -30, 0, 25) creditsTitle.Position = UDim2.new(0, 10, 0, 5) creditsTitle.BackgroundTransparency = 1 creditsTitle.Text = "Script Credits" creditsTitle.TextColor3 = Color3.fromRGB(100, 200, 255) creditsTitle.TextSize = 16 creditsTitle.Font = Enum.Font.SourceSansBold creditsTitle.TextXAlignment = Enum.TextXAlignment.Left creditsTitle.ZIndex = 16 creditsTitle.Parent = creditsFrame local creditsText = Instance.new("TextLabel") creditsText.Size = UDim2.new(1, -30, 0, 45) creditsText.Position = UDim2.new(0, 10, 0, 30) creditsText.BackgroundTransparency = 1 creditsText.Text = "Idea by: FraudDeciever\nThank you for the concept!" creditsText.TextColor3 = Color3.fromRGB(255, 255, 255) creditsText.TextSize = 14 creditsText.Font = Enum.Font.SourceSans creditsText.TextXAlignment = Enum.TextXAlignment.Left creditsText.TextYAlignment = Enum.TextYAlignment.Top creditsText.ZIndex = 16 creditsText.Parent = creditsFrame local closeButton = Instance.new("TextButton") closeButton.Size = UDim2.new(0, 25, 0, 25) closeButton.Position = UDim2.new(1, -30, 0, 5) closeButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) closeButton.BorderSizePixel = 0 closeButton.Text = "X" closeButton.TextColor3 = Color3.fromRGB(255, 255, 255) closeButton.TextSize = 16 closeButton.Font = Enum.Font.SourceSansBold closeButton.ZIndex = 17 closeButton.Parent = creditsFrame local closeCorner = Instance.new("UICorner") closeCorner.CornerRadius = UDim.new(0, 6) closeCorner.Parent = closeButton closeButton.MouseButton1Click:Connect(function() creditsFrame:TweenPosition( UDim2.new(1, 20, 1, -100), Enum.EasingDirection.In, Enum.EasingStyle.Back, 0.3, true, function() creditsFrame.Visible = false end ) end) creditsFrame.Position = UDim2.new(1, 20, 1, -100) task.wait(0.5) creditsFrame:TweenPosition( UDim2.new(1, -300, 1, -100), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.5, true ) local toggleButton = Instance.new("TextButton") toggleButton.Size = UDim2.new(0, 150, 0, 60) toggleButton.Position = UDim2.new(0.5, -75, 0.85, 0) toggleButton.BackgroundColor3 = Color3.fromRGB(50, 150, 50) toggleButton.BorderSizePixel = 3 toggleButton.BorderColor3 = Color3.fromRGB(255, 255, 255) toggleButton.Text = "START DRIVING" toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255) toggleButton.TextSize = 20 toggleButton.Font = Enum.Font.SourceSansBold toggleButton.Modal = true toggleButton.Active = true toggleButton.ZIndex = 10 toggleButton.Parent = screenGui local toggleCorner = Instance.new("UICorner") toggleCorner.CornerRadius = UDim.new(0, 10) toggleCorner.Parent = toggleButton local speedometerFrame = Instance.new("Frame") speedometerFrame.Size = UDim2.new(0, 200, 0, 80) speedometerFrame.Position = UDim2.new(0.5, -100, 0, 20) speedometerFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30) speedometerFrame.BackgroundTransparency = 0.3 speedometerFrame.BorderSizePixel = 2 speedometerFrame.BorderColor3 = Color3.fromRGB(255, 255, 255) speedometerFrame.Visible = false speedometerFrame.ZIndex = 10 speedometerFrame.Parent = screenGui local speedometerCorner = Instance.new("UICorner") speedometerCorner.CornerRadius = UDim.new(0, 12) speedometerCorner.Parent = speedometerFrame local speedLabel = Instance.new("TextLabel") speedLabel.Size = UDim2.new(1, 0, 0.6, 0) speedLabel.Position = UDim2.new(0, 0, 0, 0) speedLabel.BackgroundTransparency = 1 speedLabel.Text = "0" speedLabel.TextColor3 = Color3.fromRGB(0, 255, 0) speedLabel.TextSize = 36 speedLabel.Font = Enum.Font.SourceSansBold speedLabel.ZIndex = 11 speedLabel.Parent = speedometerFrame local unitLabel = Instance.new("TextLabel") unitLabel.Size = UDim2.new(1, 0, 0.4, 0) unitLabel.Position = UDim2.new(0, 0, 0.6, 0) unitLabel.BackgroundTransparency = 1 unitLabel.Text = "Studs/Hour" unitLabel.TextColor3 = Color3.fromRGB(200, 200, 200) unitLabel.TextSize = 16 unitLabel.Font = Enum.Font.SourceSans unitLabel.ZIndex = 11 unitLabel.Parent = speedometerFrame local controlsFrame = Instance.new("Frame") controlsFrame.Size = UDim2.new(0, 300, 0, 200) controlsFrame.Position = UDim2.new(0, 20, 1, -220) controlsFrame.BackgroundTransparency = 1 controlsFrame.Visible = false controlsFrame.ZIndex = 5 controlsFrame.Parent = screenGui local function createControlButton(text, position, size) local button = Instance.new("TextButton") button.Size = size or UDim2.new(0, 80, 0, 80) button.Position = position button.BackgroundColor3 = Color3.fromRGB(70, 70, 70) button.BackgroundTransparency = 0.3 button.BorderSizePixel = 2 button.BorderColor3 = Color3.fromRGB(200, 200, 200) button.Text = text button.TextColor3 = Color3.fromRGB(255, 255, 255) button.TextSize = 24 button.Font = Enum.Font.SourceSansBold button.Modal = true button.Active = true button.ZIndex = 10 button.Parent = controlsFrame local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, 12) corner.Parent = button return button end local upButton = createControlButton("W", UDim2.new(0, 110, 0, 0)) local leftButton = createControlButton("A", UDim2.new(0, 20, 0, 90)) local downButton = createControlButton("S", UDim2.new(0, 110, 0, 90)) local rightButton = createControlButton("D", UDim2.new(0, 200, 0, 90)) local function setupMobileButton(button, key) local isPressed = false button.MouseButton1Down:Connect(function() isPressed = true keysPressed[key] = true button.BackgroundColor3 = Color3.fromRGB(100, 200, 100) end) button.MouseButton1Up:Connect(function() isPressed = false keysPressed[key] = false button.BackgroundColor3 = Color3.fromRGB(70, 70, 70) end) button.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.Touch then isPressed = true keysPressed[key] = true button.BackgroundColor3 = Color3.fromRGB(100, 200, 100) end end) button.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.Touch then isPressed = false keysPressed[key] = false button.BackgroundColor3 = Color3.fromRGB(70, 70, 70) end end) button.MouseLeave:Connect(function() if isPressed then isPressed = false keysPressed[key] = false button.BackgroundColor3 = Color3.fromRGB(70, 70, 70) end end) end setupMobileButton(upButton, "W") setupMobileButton(leftButton, "A") setupMobileButton(downButton, "S") setupMobileButton(rightButton, "D") local function createCarBase() if carBase then pcall(function() carBase:Destroy() end) end carBase = Instance.new("Part") carBase.Name = "CarBase" carBase.Size = Vector3.new(6, 1, 10) carBase.Transparency = 1 carBase.CanCollide = false carBase.Anchored = false carBase.CFrame = rootPart.CFrame carBase.Parent = workspace bodyVelocity = Instance.new("BodyVelocity") bodyVelocity.MaxForce = Vector3.new(100000, 0, 100000) bodyVelocity.Velocity = Vector3.new(0, 0, 0) bodyVelocity.Parent = carBase bodyGyro = Instance.new("BodyGyro") bodyGyro.MaxTorque = Vector3.new(0, 100000, 0) bodyGyro.P = 10000 bodyGyro.Parent = carBase weld = Instance.new("Weld") weld.Part0 = carBase weld.Part1 = rootPart weld.C0 = CFrame.new(0, 3, 0) weld.Parent = carBase local yRotation = select(1, rootPart.CFrame:ToEulerAnglesYXZ()) targetRotation = yRotation end local function toggleDriving() isDriving = not isDriving if isDriving then createCarBase() task.wait(0.05) humanoid.WalkSpeed = 0 humanoid.JumpPower = 0 humanoid.Sit = true toggleButton.Text = "STOP DRIVING" toggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50) controlsFrame.Visible = true speedometerFrame.Visible = true else if carBase then pcall(function() carBase:Destroy() end) carBase = nil end task.wait(0.05) humanoid.Sit = false humanoid.WalkSpeed = originalWalkSpeed humanoid.JumpPower = originalJumpPower currentSpeed = 0 toggleButton.Text = "START DRIVING" toggleButton.BackgroundColor3 = Color3.fromRGB(50, 150, 50) controlsFrame.Visible = false speedometerFrame.Visible = false for key, _ in pairs(keysPressed) do keysPressed[key] = false end upButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70) leftButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70) downButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70) rightButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70) end end toggleButton.Activated:Connect(function() toggleDriving() end) userInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.E then toggleDriving() end if input.KeyCode == Enum.KeyCode.W then keysPressed.W = true end if input.KeyCode == Enum.KeyCode.A then keysPressed.A = true end if input.KeyCode == Enum.KeyCode.S then keysPressed.S = true end if input.KeyCode == Enum.KeyCode.D then keysPressed.D = true end end) userInputService.InputEnded:Connect(function(input) if input.KeyCode == Enum.KeyCode.W then keysPressed.W = false end if input.KeyCode == Enum.KeyCode.A then keysPressed.A = false end if input.KeyCode == Enum.KeyCode.S then keysPressed.S = false end if input.KeyCode == Enum.KeyCode.D then keysPressed.D = false end end) local lastPosition = nil local lastTime = tick() local connection = runService.Heartbeat:Connect(function(deltaTime) if not isDriving or not carBase or not bodyVelocity or not bodyGyro then return end if keysPressed.W then currentSpeed = math.min(currentSpeed + acceleration, drivingSpeed) elseif keysPressed.S then currentSpeed = math.max(currentSpeed - deceleration, -drivingSpeed * 0.5) else if currentSpeed > 0 then currentSpeed = math.max(currentSpeed - friction, 0) elseif currentSpeed < 0 then currentSpeed = math.min(currentSpeed + friction, 0) end end if keysPressed.A then targetRotation = targetRotation + turningSpeed * deltaTime end if keysPressed.D then targetRotation = targetRotation - turningSpeed * deltaTime end bodyGyro.CFrame = CFrame.Angles(0, targetRotation, 0) local direction = bodyGyro.CFrame.LookVector bodyVelocity.Velocity = direction * currentSpeed local currentTime = tick() local currentPosition = carBase.Position if lastPosition then local distanceTraveled = (currentPosition - lastPosition).Magnitude local timeDelta = currentTime - lastTime if timeDelta > 0 then local studsPerSecond = distanceTraveled / timeDelta local displaySpeed = math.floor(studsPerSecond) displaySpeed = math.clamp(displaySpeed, 0, 60) speedLabel.Text = string.format("%d", displaySpeed) if displaySpeed < 20 then speedLabel.TextColor3 = Color3.fromRGB(0, 255, 0) elseif displaySpeed < 40 then speedLabel.TextColor3 = Color3.fromRGB(255, 255, 0) else speedLabel.TextColor3 = Color3.fromRGB(255, 0, 0) end end end lastPosition = currentPosition lastTime = currentTime if carBase and carBase.Parent then carBase.CFrame = CFrame.new(carBase.Position.X, carBase.Position.Y, carBase.Position.Z) * CFrame.Angles(0, targetRotation, 0) end end) player.CharacterAdded:Connect(function(newChar) character = newChar humanoid = character:WaitForChild("Humanoid") rootPart = character:WaitForChild("HumanoidRootPart") isDriving = false currentSpeed = 0 if carBase then pcall(function() carBase:Destroy() end) carBase = nil end toggleButton.Text = "START DRIVING" toggleButton.BackgroundColor3 = Color3.fromRGB(50, 150, 50) controlsFrame.Visible = false speedometerFrame.Visible = false end)