driv me car
Key RequiredUniversal

driv me car

Universal ScriptAstellAstell 767 views 947 executesUpdated Nov 22, 2025
Unrated
00
Lua Script•659 lines (24351 chars)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local driving = Instance.new("ScreenGui")
local resolution = Instance.new("Frame")
local shaker = Instance.new("Frame")
local UIAspectRatioConstraint = Instance.new("UIAspectRatioConstraint")
driving.Name = "driving"
driving.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
driving.IgnoreGuiInset = true
driving.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
resolution.Name = "resolution"
resolution.Parent = driving
resolution.AnchorPoint = Vector2.new(0.5, 0.5)
resolution.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
resolution.BackgroundTransparency = 1.000
resolution.BorderColor3 = Color3.fromRGB(0, 0, 0)
resolution.BorderSizePixel = 0
resolution.Position = UDim2.new(0.5, 0, 0.5, 0)
resolution.Size = UDim2.new(0, 850, 0, 830)
UIAspectRatioConstraint.Parent = resolution
shaker.Name = "shaker"
shaker.Parent = resolution
shaker.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
shaker.BackgroundTransparency = 1.000
shaker.BorderColor3 = Color3.fromRGB(0, 0, 0)
shaker.BorderSizePixel = 0
shaker.Size = UDim2.new(1, 0, 1, 0)

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local camera = workspace.CurrentCamera
camera.FieldOfView = 120
humanoid.AutoRotate = false

local playerGui = player:WaitForChild("PlayerGui")
local drivingGui = playerGui:WaitForChild("driving")
local resolutionFrame = drivingGui:WaitForChild("resolution")
local shakerFrame = resolutionFrame:WaitForChild("shaker")

local GEAR_POSITIONS = {
	[1] = {position = UDim2.new(0.6, 0, 0.77, 0), rotation = -20},
	[3] = {position = UDim2.new(0.717, 0, 0.755, 0), rotation = 0},
	[6] = {position = UDim2.new(0.8, 0, 0.77, 0), rotation = 20}
}

local isDriving = true
local hiddenfling = true
local currentSpeed = 0
local acceleration = 20
local deceleration = 30
local reverseSpeed = -20
local turnSpeed = 2
local steerSensitivity = 0.6
local steerDamping = 8

local GEAR_SPEEDS = {
	[1] = 50,
	[3] = 75,
	[6] = 100
}

local isClicking = false
local interactingWith = nil
local currentGear = 1
local steerRotation = 0
local steerAttachPoint = nil
local initialMousePos = nil
local initialMouseAngle = 0
local initialSteerRotation = 0
local targetSteerRotation = 0


--borders
local border1 = Instance.new("Frame")
local border2 = Instance.new("Frame")
local border3 = Instance.new("Frame")
local border4 = Instance.new("Frame")
border1.Name = "border1"
border1.Parent = shaker
border1.AnchorPoint = Vector2.new(0.5, 0.5)
border1.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
border1.BorderColor3 = Color3.fromRGB(0, 0, 0)
border1.BorderSizePixel = 0
border1.Position = UDim2.new(-1, 0, 0.5, 0)
border1.Size = UDim2.new(2, 0, 2, 0)
border1.ZIndex = 10
border2.Name = "border2"
border2.Parent = shaker
border2.AnchorPoint = Vector2.new(0.5, 0.5)
border2.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
border2.BorderColor3 = Color3.fromRGB(0, 0, 0)
border2.BorderSizePixel = 0
border2.Position = UDim2.new(2, 0, 0.5, 0)
border2.Size = UDim2.new(2, 0, 2, 0)
border2.ZIndex = 10
border3.Name = "border3"
border3.Parent = shaker
border3.AnchorPoint = Vector2.new(0.5, 0.5)
border3.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
border3.BorderColor3 = Color3.fromRGB(0, 0, 0)
border3.BorderSizePixel = 0
border3.Position = UDim2.new(0.5, 0, -1, 0)
border3.Rotation = 90.000
border3.Size = UDim2.new(2, 0, 2, 0)
border3.ZIndex = 10
border4.Name = "border4"
border4.Parent = shaker
border4.AnchorPoint = Vector2.new(0.5, 0.5)
border4.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
border4.BorderColor3 = Color3.fromRGB(0, 0, 0)
border4.BorderSizePixel = 0
border4.Position = UDim2.new(0.5, 0, 2, 0)
border4.Rotation = 90.000
border4.Size = UDim2.new(2, 0, 2, 0)
border4.ZIndex = 10

--interior
local dashboard = Instance.new("ImageLabel")
local roof = Instance.new("ImageLabel")
local steer = Instance.new("ImageLabel")
local mirror = Instance.new("ImageLabel")
local card = Instance.new("ImageLabel")
local gearshift = Instance.new("ImageLabel")
local kris = Instance.new("ImageLabel")
local asgore = Instance.new("ImageLabel")
mirror.Name = "mirror"
mirror.Parent = shaker
mirror.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
mirror.BackgroundTransparency = 1.000
mirror.BorderColor3 = Color3.fromRGB(0, 0, 0)
mirror.BorderSizePixel = 0
mirror.Position = UDim2.new(0.660000026, 0, 0, -5)
mirror.Size = UDim2.new(0, 271, 0, 164)
mirror.Image = "rbxassetid://108148370121980"
mirror.ScaleType = Enum.ScaleType.Fit
mirror.ResampleMode = Enum.ResamplerMode.Pixelated
card.Name = "card"
card.Parent = mirror
card.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
card.BackgroundTransparency = 1.000
card.BorderColor3 = Color3.fromRGB(0, 0, 0)
card.BorderSizePixel = 0
card.Position = UDim2.new(0, 10, 0, 160)
card.Size = UDim2.new(0, 220, 0, 116)
card.Image = "rbxassetid://118580044724001"
card.ScaleType = Enum.ScaleType.Fit
card.ResampleMode = Enum.ResamplerMode.Pixelated
gearshift.Name = "gear shift"
gearshift.Parent = shaker
gearshift.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
gearshift.BackgroundTransparency = 1.000
gearshift.BorderColor3 = Color3.fromRGB(0, 0, 0)
gearshift.BorderSizePixel = 0
gearshift.Position = UDim2.new(0.600000024, 0, 0.769999981, 0)
gearshift.Rotation = -20.000
gearshift.Size = UDim2.new(0, 119, 0, 211)
gearshift.Image = "rbxassetid://73135020398376"
gearshift.ZIndex = 2
gearshift.ScaleType = Enum.ScaleType.Fit
gearshift.ResampleMode = Enum.ResamplerMode.Pixelated
kris.Name = "kris"
kris.Parent = shaker
kris.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
kris.BackgroundTransparency = 1.000
kris.BorderColor3 = Color3.fromRGB(0, 0, 0)
kris.BorderSizePixel = 0
kris.Position = UDim2.new(0.875903606, 0, 0.532530129, 0)
kris.Size = UDim2.new(0, 78, 0, 125)
kris.Image = "rbxassetid://104835832385432"
kris.ZIndex = 2
kris.ScaleType = Enum.ScaleType.Fit
kris.ResampleMode = Enum.ResamplerMode.Pixelated
local krisInitialPosition = kris.Position
asgore.Name = "asgore"
asgore.Parent = shaker
asgore.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
asgore.BackgroundTransparency = 1.000
asgore.BorderColor3 = Color3.fromRGB(0, 0, 0)
asgore.BorderSizePixel = 0
asgore.Position = UDim2.new(-0.0469879508, 0, 0.385542154, 0)
asgore.Size = UDim2.new(0, 322, 0, 530)
asgore.ZIndex = 8
asgore.Image = "rbxassetid://113112687203505"
asgore.ScaleType = Enum.ScaleType.Fit
asgore.ResampleMode = Enum.ResamplerMode.Pixelated
local asgoreInitialPosition = asgore.Position
dashboard.Name = "dashboard"
dashboard.Parent = shaker
dashboard.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
dashboard.BackgroundTransparency = 1.000
dashboard.BorderColor3 = Color3.fromRGB(0, 0, 0)
dashboard.BorderSizePixel = 0
dashboard.Position = UDim2.new(-0.130120486, 0, 0.625301182, 0)
dashboard.Size = UDim2.new(0, 971, 0, 350)
dashboard.Image = "rbxassetid://130672484950006"
dashboard.ScaleType = Enum.ScaleType.Fit
dashboard.ResampleMode = Enum.ResamplerMode.Pixelated
roof.Name = "roof"
roof.Parent = shaker
roof.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
roof.BackgroundTransparency = 1.000
roof.BorderColor3 = Color3.fromRGB(0, 0, 0)
roof.BorderSizePixel = 0
roof.Position = UDim2.new(-0.0170000009, 0, 0, -5)
roof.Size = UDim2.new(0, 550, 0, 82)
roof.Image = "rbxassetid://138841128898473"
roof.ScaleType = Enum.ScaleType.Fit
roof.ResampleMode = Enum.ResamplerMode.Pixelated
steer.Name = "steer"
steer.Parent = shaker
steer.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
steer.BackgroundTransparency = 1.000
steer.BorderColor3 = Color3.fromRGB(0, 0, 0)
steer.BorderSizePixel = 0
steer.Position = UDim2.new(-0.008433735, 0, 0.702409625, 0)
steer.Size = UDim2.new(0, 360, 0, 369)
steer.ZIndex = 2
steer.Image = "rbxassetid://135660240933184"
steer.ScaleType = Enum.ScaleType.Fit
steer.ResampleMode = Enum.ResamplerMode.Pixelated

local arm = Instance.new("ImageLabel")
arm.Name = "Arm"
arm.Parent = shakerFrame
arm.Size = UDim2.new(0, 295, 0, 790)
arm.Image = "rbxassetid://92773761241483"
arm.ImageRectSize = Vector2.new(154, 411)
arm.ImageRectOffset = Vector2.new(0, 0)
arm.BackgroundTransparency = 1.0
arm.ResampleMode = Enum.ResamplerMode.Pixelated
arm.ScaleType = Enum.ScaleType.Fit
arm.ZIndex = 4
arm.AnchorPoint = Vector2.new(0.5, 1)

--hitboxes
local hitbox = Instance.new("Frame")
local hitbox_2 = Instance.new("Frame")
local hitbox_3 = Instance.new("Frame")
local hitbox_4 = Instance.new("Frame")
local hitbox_5 = Instance.new("Frame")
local hitbox_6 = Instance.new("Frame")
local hitbox_7 = Instance.new("Frame")
local hitbox_8 = Instance.new("Frame")
local hitbox_9 = Instance.new("Frame")
local hitbox_10 = Instance.new("Frame")
local hitbox_11 = Instance.new("Frame")
local hitbox_12 = Instance.new("Frame")
local hitbox_13 = Instance.new("Frame")
local hitbox_14 = Instance.new("Frame")
local honk = Instance.new("Frame")
hitbox.Name = "hitbox"
hitbox.Parent = steer
hitbox.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox.BackgroundTransparency = 1.000
hitbox.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox.BorderSizePixel = 0
hitbox.Position = UDim2.new(0, 314, 0, 163)
hitbox.Size = UDim2.new(0, 38, 0, 82)
hitbox_2.Name = "hitbox"
hitbox_2.Parent = steer
hitbox_2.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_2.BackgroundTransparency = 1.000
hitbox_2.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_2.BorderSizePixel = 0
hitbox_2.Position = UDim2.new(0, 282, 0, 46)
hitbox_2.Rotation = -40.000
hitbox_2.Size = UDim2.new(0, 38, 0, 82)
hitbox_3.Name = "hitbox"
hitbox_3.Parent = steer
hitbox_3.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_3.BackgroundTransparency = 1.000
hitbox_3.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_3.BorderSizePixel = 0
hitbox_3.Position = UDim2.new(0, 222, 0, 0)
hitbox_3.Rotation = -60.000
hitbox_3.Size = UDim2.new(0, 38, 0, 82)
hitbox_4.Name = "hitbox"
hitbox_4.Parent = steer
hitbox_4.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_4.BackgroundTransparency = 1.000
hitbox_4.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_4.BorderSizePixel = 0
hitbox_4.Position = UDim2.new(0, 161, 0, -16)
hitbox_4.Rotation = -90.000
hitbox_4.Size = UDim2.new(0, 38, 0, 82)
hitbox_5.Name = "hitbox"
hitbox_5.Parent = steer
hitbox_5.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_5.BackgroundTransparency = 1.000
hitbox_5.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_5.BorderSizePixel = 0
hitbox_5.Position = UDim2.new(0, 90, 0, 0)
hitbox_5.Rotation = 60.000
hitbox_5.Size = UDim2.new(0, 38, 0, 82)
hitbox_6.Name = "hitbox"
hitbox_6.Parent = steer
hitbox_6.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_6.BackgroundTransparency = 1.000
hitbox_6.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_6.BorderSizePixel = 0
hitbox_6.Position = UDim2.new(0, 307, 0, 92)
hitbox_6.Rotation = -20.000
hitbox_6.Size = UDim2.new(0, 38, 0, 82)
hitbox_7.Name = "hitbox"
hitbox_7.Parent = steer
hitbox_7.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_7.BackgroundTransparency = 1.000
hitbox_7.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_7.BorderSizePixel = 0
hitbox_7.Position = UDim2.new(0, 39, 0, 46)
hitbox_7.Rotation = 40.000
hitbox_7.Size = UDim2.new(0, 38, 0, 82)
hitbox_8.Name = "hitbox"
hitbox_8.Parent = steer
hitbox_8.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_8.BackgroundTransparency = 1.000
hitbox_8.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_8.BorderSizePixel = 0
hitbox_8.Position = UDim2.new(0, 13, 0, 92)
hitbox_8.Rotation = 20.000
hitbox_8.Size = UDim2.new(0, 38, 0, 82)
hitbox_9.Name = "hitbox"
hitbox_9.Parent = steer
hitbox_9.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_9.BackgroundTransparency = 1.000
hitbox_9.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_9.BorderSizePixel = 0
hitbox_9.Position = UDim2.new(0, 7, 0, 167)
hitbox_9.Size = UDim2.new(0, 38, 0, 82)
hitbox_10.Name = "hitbox"
hitbox_10.Parent = steer
hitbox_10.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_10.BackgroundTransparency = 1.000
hitbox_10.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_10.BorderSizePixel = 0
hitbox_10.Position = UDim2.new(0, 25, 0, 231)
hitbox_10.Rotation = -20.000
hitbox_10.Size = UDim2.new(0, 38, 0, 82)
hitbox_11.Name = "hitbox"
hitbox_11.Parent = steer
hitbox_11.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_11.BackgroundTransparency = 1.000
hitbox_11.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_11.BorderSizePixel = 0
hitbox_11.Position = UDim2.new(0, 63, 0, 270)
hitbox_11.Rotation = -50.000
hitbox_11.Size = UDim2.new(0, 38, 0, 82)
hitbox_12.Name = "hitbox"
hitbox_12.Parent = steer
hitbox_12.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_12.BackgroundTransparency = 1.000
hitbox_12.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_12.BorderSizePixel = 0
hitbox_12.Position = UDim2.new(0, 269, 0, 270)
hitbox_12.Rotation = 50.000
hitbox_12.Size = UDim2.new(0, 38, 0, 82)
hitbox_13.Name = "hitbox"
hitbox_13.Parent = steer
hitbox_13.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_13.BackgroundTransparency = 1.000
hitbox_13.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_13.BorderSizePixel = 0
hitbox_13.Position = UDim2.new(0, 299, 0, 217)
hitbox_13.Rotation = 20.000
hitbox_13.Size = UDim2.new(0, 38, 0, 82)
hitbox_14.Name = "hitbox"
hitbox_14.Parent = steer
hitbox_14.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
hitbox_14.BackgroundTransparency = 1.000
hitbox_14.BorderColor3 = Color3.fromRGB(0, 0, 0)
hitbox_14.BorderSizePixel = 0
hitbox_14.Position = UDim2.new(0, 161, 0, 270)
hitbox_14.Rotation = 90.000
hitbox_14.Size = UDim2.new(0, 38, 0, 148)
honk.Name = "honk"
honk.Parent = steer
honk.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
honk.BackgroundTransparency = 1.000
honk.BorderColor3 = Color3.fromRGB(0, 0, 0)
honk.BorderSizePixel = 0
honk.Position = UDim2.new(0, 130, 0, 138)
honk.Size = UDim2.new(0, 99, 0, 93)

local CONTROLS = Instance.new("ImageLabel") -- there was supposed to be a full on lil introduction but didnt get to it
CONTROLS.Name = "CONTROLS"
CONTROLS.Parent = driving
CONTROLS.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
CONTROLS.BackgroundTransparency = 1.000
CONTROLS.BorderColor3 = Color3.fromRGB(0, 0, 0)
CONTROLS.BorderSizePixel = 0
CONTROLS.Size = UDim2.new(1, 0, 1, 0)
CONTROLS.Image = "rbxassetid://134259058221068"
CONTROLS.ImageTransparency = 1.000
CONTROLS.ScaleType = Enum.ScaleType.Fit
CONTROLS.ResampleMode = Enum.ResamplerMode.Pixelated

local honkSound = Instance.new("Sound")
honkSound.SoundId = "rbxassetid://70558473239102"
honkSound.Parent = shakerFrame
honkSound.Volume = 10

local music = Instance.new("Sound")
local equalizer1 = Instance.new("EqualizerSoundEffect")
local equalizer2 = Instance.new("EqualizerSoundEffect")
local distortionEffect = Instance.new("DistortionSoundEffect")
music.SoundId = "rbxassetid://124785694045206"
music.Volume = 10
music.PlaybackSpeed = 0.1
music.Looped = true
music.Parent = shakerFrame
equalizer1.HighGain = 0
equalizer1.LowGain = 100
equalizer1.MidGain = 0
equalizer1.Priority = 1
equalizer1.Parent = music
equalizer2.HighGain = 0
equalizer2.LowGain = 100
equalizer2.MidGain = 0
equalizer2.Priority = 1
equalizer2.Parent = music
distortionEffect.Level = 0.4
distortionEffect.Priority = 2
distortionEffect.Parent = music
music:Play()

local steerImg = shakerFrame:WaitForChild("steer")
local gearImg = shakerFrame:WaitForChild("gear shift")
local honkFrame = steerImg:WaitForChild("honk")
local mirrorImg = shakerFrame:WaitForChild("mirror")

local currentBounceOffset = 0
local bounceDecay = 0.5
local bounceMultiplier = 0.01
local loudnessThreshold = 5555

local function getMousePosition()
	local mousePos = UserInputService:GetMouseLocation()
	local screenSize = resolutionFrame.AbsoluteSize
	local screenPos = resolutionFrame.AbsolutePosition
	return Vector2.new(mousePos.X - screenPos.X, mousePos.Y - screenPos.Y)
end

local function isMouseOverGuiObject(guiObject)
	local mouse = getMousePosition()
	local absPos = guiObject.AbsolutePosition - resolutionFrame.AbsolutePosition
	local absSize = guiObject.AbsoluteSize
	return mouse.X >= absPos.X and mouse.X <= absPos.X + absSize.X and
		mouse.Y >= absPos.Y and mouse.Y <= absPos.Y + absSize.Y
end

local function getNearestHitbox(mousePos)
	local nearestHitbox = nil
	local nearestDistance = math.huge
	for _, child in pairs(steerImg:GetChildren()) do
		if child.Name == "hitbox" and child:IsA("Frame") then
			local hitboxCenter = child.AbsolutePosition + child.AbsoluteSize / 2 - resolutionFrame.AbsolutePosition
			local distance = (Vector2.new(hitboxCenter.X, hitboxCenter.Y) - mousePos).Magnitude
			if distance < nearestDistance then
				nearestDistance = distance
				nearestHitbox = child
			end
		end
	end
	return nearestHitbox
end

local function getGearFromMouseX(mouseX)
	local screenWidth = resolutionFrame.AbsoluteSize.X
	local relativeX = mouseX / screenWidth
	if relativeX < 0.65 then
		return 1
	elseif relativeX > 0.75 then
		return 6
	else
		return 3
	end
end

local function updateArm()
	local mousePos = getMousePosition()
	local screenHeight = resolutionFrame.AbsoluteSize.Y
	if screenHeight > 0 then
		local mouseYRatio = math.clamp(mousePos.Y / screenHeight, 0, 1)
		local yOffset = (mouseYRatio - 0.5) * 20
		asgore.Position = UDim2.new(asgoreInitialPosition.X.Scale, asgoreInitialPosition.X.Offset, asgoreInitialPosition.Y.Scale, asgoreInitialPosition.Y.Offset + yOffset)
	end
	local screenSize = resolutionFrame.AbsoluteSize
	local target = Vector2.new(mousePos.X, mousePos.Y)

	if interactingWith == "steer" and steerAttachPoint then
		local steerCenter = steerImg.AbsolutePosition + steerImg.AbsoluteSize / 2 - resolutionFrame.AbsolutePosition
		local currentMouseAngle = math.atan2(mousePos.Y - steerCenter.Y, mousePos.X - steerCenter.X)
		local angleDelta = currentMouseAngle - initialMouseAngle
		if angleDelta > math.pi then
			angleDelta = angleDelta - (2 * math.pi)
		elseif angleDelta < -math.pi then
			angleDelta = angleDelta + (2 * math.pi)
		end
		targetSteerRotation = initialSteerRotation + math.deg(angleDelta) * steerSensitivity
		targetSteerRotation = math.clamp(targetSteerRotation, -70, 90)
		local hitboxCenter = steerAttachPoint.AbsolutePosition + steerAttachPoint.AbsoluteSize / 2 - resolutionFrame.AbsolutePosition
		local radius = (Vector2.new(hitboxCenter.X, hitboxCenter.Y) - Vector2.new(steerCenter.X, steerCenter.Y)).Magnitude
		local initialHitboxAngle = math.atan2(hitboxCenter.Y - steerCenter.Y, hitboxCenter.X - steerCenter.X)
		local currentHitboxAngle = initialHitboxAngle + math.rad(steerRotation)
		target = Vector2.new(steerCenter.X + math.cos(currentHitboxAngle) * radius, steerCenter.Y + math.sin(currentHitboxAngle) * radius)
	elseif interactingWith == "gearshift" then
		currentGear = getGearFromMouseX(mousePos.X)
		local gearData = GEAR_POSITIONS[currentGear]
		target = mousePos
		gearImg.Position = gearData.position
		gearImg.Rotation = gearData.rotation
	end
	local centerScreen = screenSize / 2
	local pivotBasePosition = Vector2.new(centerScreen.X, screenSize.Y * 1.2)
	local mouseOffset = mousePos - centerScreen
	local pivotPoint = pivotBasePosition + Vector2.new(mouseOffset.X * 0.85, mouseOffset.Y * 1)
	local gearshiftYOffset = interactingWith == "gearshift" and -150 or 0
	local steerYOffset = interactingWith == "steer" and -150 or 0
	local targetWithOffset = Vector2.new(target.X, target.Y + (gearshiftYOffset + steerYOffset))
	local vectorToTarget = targetWithOffset - pivotPoint
	local angleToTarget = math.atan2(vectorToTarget.Y, vectorToTarget.X)

	arm.Rotation = math.deg(angleToTarget) + 90
	arm.Position = UDim2.new(0, pivotPoint.X, 0, pivotPoint.Y)
	arm.Size = UDim2.new(0, 295, 0, 790)
end


RunService.Stepped:Connect(function()
	for _, otherPlayer in pairs(Players:GetPlayers()) do
		if otherPlayer ~= player and otherPlayer.Character then
			for _, part in pairs(otherPlayer.Character:GetDescendants()) do
				if part:IsA("BasePart") then
					part.CanCollide = false
				end
			end
		end
	end
end)

UserInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		isClicking = true
		initialMousePos = getMousePosition()
		arm.ImageRectOffset = Vector2.new(154, 0)
		local mousePos = getMousePosition()
		if isMouseOverGuiObject(honkFrame) then
			honkSound:Play()
		elseif isMouseOverGuiObject(steerImg) then
			interactingWith = "steer"
			steerAttachPoint = getNearestHitbox(mousePos)
			if steerAttachPoint then
				local steerCenter = steerImg.AbsolutePosition + steerImg.AbsoluteSize / 2 - resolutionFrame.AbsolutePosition
				initialMouseAngle = math.atan2(mousePos.Y - steerCenter.Y, mousePos.X - steerCenter.X)
				initialSteerRotation = steerRotation
			end
		elseif isMouseOverGuiObject(gearImg) then
			interactingWith = "gearshift"
		end
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		isClicking = false
		initialMousePos = nil
		arm.ImageRectOffset = Vector2.new(0, 0)
		if interactingWith == "steer" then
			targetSteerRotation = 0
		end
		interactingWith = nil
		steerAttachPoint = nil
	end
end)

local function onRenderStepped(dt)
	updateArm()
	local loudness = music.PlaybackLoudness
	currentBounceOffset = currentBounceOffset * bounceDecay
	if loudness > loudnessThreshold then
		local newBounce = (loudness - loudnessThreshold) * bounceMultiplier
		if newBounce > currentBounceOffset then
			currentBounceOffset = newBounce
		end
	end
	local targetPosition = UDim2.new(krisInitialPosition.X.Scale, krisInitialPosition.X.Offset, krisInitialPosition.Y.Scale, krisInitialPosition.Y.Offset - currentBounceOffset)
	kris.Position = targetPosition
	local musicSway = 0
	if currentBounceOffset > 0.005 then
		local swayFrequency = 8
		local swayAmplitude = currentBounceOffset * 3
		musicSway = math.sin(tick() * swayFrequency) * swayAmplitude
	end
	if not isDriving then return end
	steerRotation = steerRotation + (targetSteerRotation - steerRotation) * steerDamping * dt
	steerImg.Rotation = steerRotation
	shakerFrame.Rotation = steerRotation * 0.05
	camera.CameraType = Enum.CameraType.Scriptable
	UserInputService.MouseBehavior = Enum.MouseBehavior.Default
	local head = character:FindFirstChild("Head")
	if head then
		camera.CFrame = CFrame.new(head.Position, head.Position + rootPart.CFrame.LookVector)
	end
	local maxSpeed = GEAR_SPEEDS[currentGear] or 50
	local moveDirection = 0
	if UserInputService:IsKeyDown(Enum.KeyCode.W) then
		moveDirection = 1
	elseif UserInputService:IsKeyDown(Enum.KeyCode.S) then
		moveDirection = -1
	end
	if moveDirection == 1 then
		currentSpeed = math.min(maxSpeed, currentSpeed + acceleration * dt)
	elseif moveDirection == -1 then
		currentSpeed = math.max(reverseSpeed, currentSpeed - acceleration * dt)
	else
		if currentSpeed > 0 then
			currentSpeed = math.max(0, currentSpeed - deceleration * dt)
		else
			currentSpeed = math.min(0, currentSpeed + deceleration * dt)
		end
	end
	local turn = 0
	if steerRotation ~= 0 then
		turn = -steerRotation / 45 * turnSpeed * (currentSpeed / maxSpeed)
	end
	local steerSway = turn * 2.5
	local asgoreTargetRotation = -steerSway
	local mirrorrot = steerSway
	mirrorImg.Rotation = mirrorImg.Rotation + (mirrorrot - mirrorImg.Rotation) * 7 * dt
	kris.Rotation = kris.Rotation + (musicSway - kris.Rotation) * 7 * dt
	asgore.Rotation = asgore.Rotation + (asgoreTargetRotation - asgore.Rotation) * 7 * dt
	if currentSpeed ~= 0 then
		rootPart.CFrame = rootPart.CFrame * CFrame.Angles(0, math.rad(turn) * dt * 60, 0)
		rootPart.Velocity = rootPart.CFrame.LookVector * currentSpeed
	else
		rootPart.Velocity = Vector3.new(0,0,0)
	end
end

RunService.RenderStepped:Connect(onRenderStepped)
RunService.Heartbeat:Connect(function()
	if hiddenfling then
		local c = Players.LocalPlayer.Character
		if c and c.Parent then
			local hrp = c:FindFirstChild("HumanoidRootPart")
			if hrp then
				local vel = hrp.Velocity
				hrp.Velocity = hrp.Velocity.Unit * Vector3.new(100000066612410000, 0, 1000000004444455000) + Vector3.new(0, 250004444000046640000, 0)
				RunService.RenderStepped:Wait()
				if c and c.Parent and hrp and hrp.Parent then
					hrp.Velocity = vel
				end
			end
		end
	end
end)

Features & Information

for the deltarune fans :)

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts