Kukirin Life Script (December 2026) – Auto Ride

PUBLISHEDUPDATED
What changed
  • 2026-12-02 — Added Script #16: Stability Guard & More.
  • 2026-11-07 — Added Script #15: Cash Farm & More.
  • 2026-11-07 — Added Script #14: Auto Wheelie Farm & More.
  • 2026-11-07 — Added Script #13: Rivo Hub.
  • 2026-11-07 — Added Script #12: Premium Features.
  • 2026-11-02 — Added Script #11: Money farm & More.
  • 2026-11-02 — Added Script #10: lose cops (click e or clikóck text for mobile) & More.
  • 2026-11-01 — Added Script #9: Ash Hub.
  • 2026-10-31 — Added Script #8: Autofarm & More.
  • 2026-10-31 — Added Script #7: auto money & More.
  • 2026-10-27 — Added Script #6: ANTI POLICE.
  • 2026-10-27 — Added Script #5: Farm & More.
  • 2026-10-26 — Added Script #4: autofarm and adjust scooter speed & More.
  • 2026-10-26 — Added Script #3: # Kukirin Life 🛴 & More.
  • 2026-10-23 — Added Script #2: Updated for Auto Wheelie Update.
1 Available ScriptFree

Grinding out cash and upgrades on a scooter without getting busted by the cops can wear you down fast, which is why using a Kukirin Life script makes cruising the big map way more fun.

You get to explore a massive city with loads of varied roads, trick out your ride with deep customization, and try to outrun responsive police chases while knocking out quests and achievements.

If you want to speed past the boring parts and test out all the best tricks and gear right now, grab the working script below and hit the streets.

Kukirin Life Script – Barrage

BarrageFree
Auto RideRide FailsafeScooter ModsWheelie AssistAuto BuyAuto Hardware
loadstring(game:HttpGet("https://barrage.cc/loader"))()
Executor compatibility changes over time. Check current reports before testing.

Script #2 Auto Farm & More (Auto Wheelie Update)

Script #2 · Auto Farm & MoreFree
Auto Farm
loadstring(game:HttpGet("https://pastefy.app/JAWlJZGn/raw"))()
Executor compatibility changes over time. Check current reports before testing.

Script #3 # Kukirin Life 🛴 & More

Script #3 · # Kukirin Life 🛴 & MoreFree
# Kukirin Life 🛴### Autofarm300/s ** 2x = 600/s **Auto halloween ( hops off for non km quests, rides for km )Auto claim ( daily rewards + money rain )Auto money rain ( walks the drops, up or down to a target )
loadstring(game:HttpGet("https://vampauth.com/v1/loaders/fe85c28a906773af461f7e9e4664303b.lua"))()
Executor compatibility changes over time. Check current reports before testing.

Script #4 autofarm and adjust scooter speed & More

Script #4 · autofarm and adjust scooter speed & MoreFree
autofarm and adjust scooter speed
loadstring(game:HttpGet("https://raw.githubusercontent.com/semhi365-max/1/refs/heads/main/kukirin%20life"))()
Executor compatibility changes over time. Check current reports before testing.

Script #5 Farm & More

Script #5 · Farm & MoreFree
FarmAuto Quests, Achievements & Daily reward claimingAuto Delivery — runs food deliveries for cashAuto Buy — grabs the fastest ride you can affordMoney Rain collectorRide
loadstring(game:HttpGet("https://pastefy.app/eKaaMva6/raw"))()
Executor compatibility changes over time. Check current reports before testing.

Script #6 ANTI POLICE

Script #6 · ANTI POLICEFree
MYSTRIX HUB ————✦ Features Included :➤ Main :Auto WheelieBalance Angle SliderSpeed Multiplier
loadstring(game:HttpGet("https://raw.githubusercontent.com/ummarxfarooq/mystrix-hub/refs/heads/main/loader"))()
Executor compatibility changes over time. Check current reports before testing.

Script #7 auto money & More

Script #7 · auto money & MoreFree
auto money
loadstring(game:HttpGet("https://gist.githubusercontent.com/bctk7kgvn8-png/fe2eb1af91d60ff8af1e90f50c599c5f/raw/4078afa7fe476100867a6e7a74cd0d0dc2d3b9cd/farm.lua"))()
Executor compatibility changes over time. Check current reports before testing.

Script #8 Autofarm & More

Script #8 · Autofarm & MoreFree
AutofarmMobile SupportAuto WheelieAdjust SpeedMore
loadstring(game:HttpGet("https://raw.githubusercontent.com/semhi365-max/1/refs/heads/main/suavley"))()
Executor compatibility changes over time. Check current reports before testing.

Script #9 Ash Hub

Script #9 · Ash HubFree
Kurkin Life speed scriptAuto Quests
loadstring(game:HttpGet("https://pastebin.com/raw/VhZrfCnS"))()
Executor compatibility changes over time. Check current reports before testing.

Script #10 lose cops (click e or clikóck text for mobile) & More

Script #10 · lose cops (click e or clikóck text for mobile) & MoreFree
lose cops (click e or clikóck text for mobile)
loadstring(game:HttpGet("https://pastebin.com/raw/zy0W7wG9"))()
Executor compatibility changes over time. Check current reports before testing.

Script #11 Money farm & More

Script #11 · Money farm & MoreFree
Money farmFrontflip
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer

-- ===== Defaults (all editable in the UI) =====
local DEFAULT_MIN_KPH = 69
local DEFAULT_MAX_KPH = 89
local DEFAULT_FLIP_DEG = 720          -- degrees/sec (720 = 2 full flips per second)
local FLOAT_HEIGHT = 25               -- studs above starting height
local FLIP_PAUSE = 0.25               -- seconds of level driving between flips
local SPEED_CHANGE_EVERY = 2          -- seconds between new random speeds
local STUDS_PER_METER = 1 / 0.28      -- Roblox standard: 1 stud = 0.28 m
-- =============================================

local function kphToStudsPerSec(kph)
	return (kph / 3.6) * STUDS_PER_METER
end

-- ---------- UI ----------
local gui = Instance.new("ScreenGui")
gui.Name = "MoneyFarmGui"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")

local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 220, 0, 200)
frame.Position = UDim2.new(0.5, -110, 0, 20)
frame.BackgroundColor3 = Color3.fromRGB(25, 25, 30)
frame.BorderSizePixel = 0
frame.Active = true
frame.Parent = gui
Instance.new("UICorner", frame).CornerRadius = UDim.new(0, 10)

local titleBar = Instance.new("TextLabel")
titleBar.Size = UDim2.new(1, 0, 0, 32)
titleBar.BackgroundColor3 = Color3.fromRGB(45, 45, 55)
titleBar.BorderSizePixel = 0
titleBar.Text = "Money Farm  (drag me)"
titleBar.TextColor3 = Color3.new(1, 1, 1)
titleBar.Font = Enum.Font.GothamBold
titleBar.TextSize = 14
titleBar.Active = true
titleBar.Parent = frame
Instance.new("UICorner", titleBar).CornerRadius = UDim.new(0, 10)

local function makeRow(labelText, defaultValue, y)
	local label = Instance.new("TextLabel")
	label.Size = UDim2.new(0, 110, 0, 28)
	label.Position = UDim2.new(0, 10, 0, y)
	label.BackgroundTransparency = 1
	label.Text = labelText
	label.TextColor3 = Color3.new(1, 1, 1)
	label.Font = Enum.Font.Gotham
	label.TextSize = 13
	label.TextXAlignment = Enum.TextXAlignment.Left
	label.Parent = frame

	local box = Instance.new("TextBox")
	box.Size = UDim2.new(0, 80, 0, 28)
	box.Position = UDim2.new(1, -90, 0, y)
	box.BackgroundColor3 = Color3.fromRGB(55, 55, 65)
	box.TextColor3 = Color3.new(1, 1, 1)
	box.Font = Enum.Font.Gotham
	box.TextSize = 14
	box.Text = tostring(defaultValue)
	box.ClearTextOnFocus = false
	box.Parent = frame
	Instance.new("UICorner", box).CornerRadius = UDim.new(0, 6)
	return box
end

local minBox = makeRow("Min speed (kph)", DEFAULT_MIN_KPH, 42)
local maxBox = makeRow("Max speed (kph)", DEFAULT_MAX_KPH, 76)
local flipBox = makeRow("Flip speed (deg/s)", DEFAULT_FLIP_DEG, 110)

local button = Instance.new("TextButton")
button.Size = UDim2.new(1, -20, 0, 40)
button.Position = UDim2.new(0, 10, 0, 150)
button.BackgroundColor3 = Color3.fromRGB(40, 170, 80)
button.TextColor3 = Color3.new(1, 1, 1)
button.Font = Enum.Font.GothamBold
button.TextSize = 16
button.Text = "Start Money Farm"
button.Parent = frame
Instance.new("UICorner", button).CornerRadius = UDim.new(0, 8)

-- ---------- Dragging (mouse + touch) ----------
do
	local dragging, dragStart, startPos
	titleBar.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1
			or input.UserInputType == Enum.UserInputType.Touch then
			dragging = true
			dragStart = input.Position
			startPos = frame.Position
			input.Changed:Connect(function()
				if input.UserInputState == Enum.UserInputState.End then
					dragging = false
				end
			end)
		end
	end)
	UserInputService.InputChanged:Connect(function(input)
		if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement
			or input.UserInputType == Enum.UserInputType.Touch) then
			local delta = input.Position - dragStart
			frame.Position = UDim2.new(
				startPos.X.Scale, startPos.X.Offset + delta.X,
				startPos.Y.Scale, startPos.Y.Offset + delta.Y
			)
		end
	end)
end

-- ---------- Farm logic ----------
local running = false
local conn

local function readNumber(box, fallback, lo, hi)
	local n = tonumber(box.Text)
	if not n then n = fallback end
	n = math.clamp(n, lo, hi)
	box.Text = tostring(n)
	return n
end

local function getVehicleRoot()
	local char = player.Character
	local hum = char and char:FindFirstChildOfClass("Humanoid")
	local seat = hum and hum.SeatPart
	if seat then
		return seat.AssemblyRootPart or seat
	end
	return nil
end

local function stop()
	running = false
	if conn then conn:Disconnect() conn = nil end
	button.Text = "Start Money Farm"
	button.BackgroundColor3 = Color3.fromRGB(40, 170, 80)
end

local function start()
	local root = getVehicleRoot()
	if not root then
		button.Text = "Sit in a vehicle first!"
		task.delay(1.5, function()
			if not running then button.Text = "Start Money Farm" end
		end)
		return
	end

	-- Read settings at the moment you press start
	local minKph = readNumber(minBox, DEFAULT_MIN_KPH, 1, 1000)
	local maxKph = readNumber(maxBox, DEFAULT_MAX_KPH, 1, 1000)
	if minKph > maxKph then
		minKph, maxKph = maxKph, minKph
		minBox.Text, maxBox.Text = tostring(minKph), tostring(maxKph)
	end
	local flipSpeed = math.rad(readNumber(flipBox, DEFAULT_FLIP_DEG, 60, 5000))

	running = true
	button.Text = "Stop Money Farm"
	button.BackgroundColor3 = Color3.fromRGB(190, 50, 50)

	local look = root.CFrame.LookVector
	local heading = Vector3.new(look.X, 0, look.Z).Unit
	local targetY = root.Position.Y + FLOAT_HEIGHT

	local function randomSpeed()
		return kphToStudsPerSec(minKph + math.random() * (maxKph - minKph))
	end
	local speed = randomSpeed()
	local lastChange = os.clock()
	local flipAngle, pauseLeft = 0, 0

	conn = RunService.Heartbeat:Connect(function(dt)
		local r = getVehicleRoot()
		if not r then stop() return end

		if os.clock() - lastChange >= SPEED_CHANGE_EVERY then
			speed = randomSpeed()
			lastChange = os.clock()
		end

		-- Full 360 backflip around the vehicle's own right axis, then a short pause
		if pauseLeft > 0 then
			pauseLeft -= dt
		else
			local step = math.min(flipSpeed * dt, 2 * math.pi - flipAngle)
			r.CFrame = r.CFrame * CFrame.Angles(-step, 0, 0)
			flipAngle += step
			if flipAngle >= 2 * math.pi - 1e-4 then
				flipAngle = 0
				pauseLeft = FLIP_PAUSE
			end
		end

		-- Float (strong correction so heavy gravity can't pull you down) + drive forward
		local yVel = math.clamp((targetY - r.Position.Y) * 12, -150, 150)
		r.AssemblyLinearVelocity = heading * speed + Vector3.new(0, yVel, 0)
	end)
end

button.MouseButton1Click:Connect(function()
	if running then stop() else start() end
end)
Executor compatibility changes over time. Check current reports before testing.

Script #12 Premium Features

Script #12 · Premium FeaturesFree
many cool features fast autofarm speed unlock and much more
loadstring(game:HttpGet("https://raw.githubusercontent.com/tacc80717-glitch/kukirinlife/refs/heads/main/kukirinlife"))()
Executor compatibility changes over time. Check current reports before testing.

Script #13 Rivo Hub

Script #13 · Rivo HubFree
⚡ Speed bypass (PC + mobile)🎨 Optik (rainbow scooter, suspension, maybach bounce)💰 Autofarm (2 modes)📦 Crate auto-opener🚓 Steal nearest police car🛡️ Anti-AFK, Player ESP, teleport to player
loadstring(game:HttpGet("https://raw.githubusercontent.com/gurungunknown96-gif/kukurin/refs/heads/main/main"))()
Executor compatibility changes over time. Check current reports before testing.

Script #14 Auto Wheelie Farm & More

Script #14 · Auto Wheelie Farm & MoreFree
Auto Wheelie FarmAuto Flip FarmFlips per Jump (1-6)Auto DeliveryAuto Buy Best ScooterAuto Buy Basic Crate
loadstring(game:HttpGet("https://raw.githubusercontent.com/ScepTsk/ServaHub.Lua/refs/heads/main/MrsScep_Lua.lua"))()
Executor compatibility changes over time. Check current reports before testing.

Script #15 Cash Farm & More

Script #15 · Cash Farm & MoreFree
Cash FarmSpeed Heck
loadstring(game:HttpGet("https://pastefy.app/lOlEkJ8b/raw"))()
Executor compatibility changes over time. Check current reports before testing.

Script #16 Stability Guard & More

Script #16 · Stability Guard & MoreFree
Stability Guard775°/SFast RiseAdvanced Stability GuardAutomatic G2 Scooter SpawnContinuous Spin Cycles
--[[
KURKIN LIFE | V10 STABILITY GUARD
Based on V10 Auto Spawn / Kuki G2 / rise=15 / fall=15 / yaw=3775.
Preserves original spin and recovery. Adds bounded planar physical assist
(X/Z only), separate seat-to-rider relative-drift monitoring, spin failure
watchdog, and idle warning. Does not anchor the G2 or use continuous PivotTo.
Client-side physics is NOT a guarantee against server corrections, network
ownership changes, lost seats, AFK disconnection, or resets.
STATIC REVIEW ONLY. Requires observation in the game before leaving unattended.
--]]

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-- Stop earlier standalone protection scripts.
local environment = getgenv and getgenv() or nil
if environment then
    for _, key in ipairs({"ScooterAntiBreakV1", "ScooterAntiBreakV2", "ScooterAFKLock"}) do
        local previous = environment[key]
        if previous and type(previous.Destroy) == "function" then
            pcall(function() previous.Destroy() end)
            environment[key] = nil
        end
    end
end

for _, name in ipairs({"SpinMenu", "ScooterCheck"}) do
    local old = playerGui:FindFirstChild(name)
    if old then old:Destroy() end
end

-- הגדרות
local targetDegrees = 5300
local waitTime = 0.050
local liftHeight = 2
-- TURBO: extremely fast vertical travel; rotation is raised only slightly.
local riseSpeed = 15        -- studs/sec (original rise cap: 6)
local descentSpeed = 15     -- studs/sec (original descent: 8)
local maxSpeed = 3775        -- degrees/sec (requested spin speed)
local finishResponse = 24
local autoSpawn = true
local autoEquip = true
local homeCFrame
local recoveryTravelled = false
local recoveryReturned = false
local travelAttempts = 0
local returnAttempts = 0

local enabled = false
local phase = "off"
local elapsed = 0
local stableTime = 0
local targetHeight = 0
local baseHeight = 0         -- height before each rise; precise stop for fast descent
local turned = 0
local previousAngle = 0
local fixedX = 0
local fixedZ = 0
local descentObserved = false

local root
local humanoid
local oldAutoRotate

local connections = {}
local effectTweens = {}
local alive = true
local random = Random.new()

-- Rider retention functions (defined below; called from OFF/cleanup).
local maintainRiderLock
local releaseRiderLock
local releaseStability
local maintainStability
local stabilityHealth

-- יצירת התפריט
local gui = Instance.new("ScreenGui")
gui.Name = "SpinMenu"
gui.ResetOnSpawn = false
gui.IgnoreGuiInset = true
gui.DisplayOrder = 20
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
gui.Parent = playerGui

local function corner(object, radius)
    local item = Instance.new("UICorner")
    item.CornerRadius = radius
    item.Parent = object
end

local function label(parent, text, size, position, dimensions)
    local item = Instance.new("TextLabel")
    item.BackgroundTransparency = 1
    item.Text = text
    item.Font = Enum.Font.FredokaOne
    item.TextSize = size
    item.TextColor3 = Color3.new(1, 1, 1)
    item.Position = position
    item.Size = dimensions
    item.ZIndex = 3
    item.Parent = parent
    return item
end

local button = Instance.new("TextButton")
button.Name = "AutoButton"
button.Size = UDim2.fromOffset(270, 100)
button.Position = UDim2.new(0, 24, 0.5, -50)
button.BackgroundColor3 = Color3.new(1, 1, 1)
button.BorderSizePixel = 0
button.Text = ""
button.AutoButtonColor = false
button.ClipsDescendants = true
button.Active = true
button.Parent = gui
corner(button, UDim.new(0.5, 0))

local surface = Instance.new("UIGradient")
surface.Color = ColorSequence.new({
    ColorSequenceKeypoint.new(0, Color3.fromRGB(50, 220, 255)),
    ColorSequenceKeypoint.new(0.38, Color3.fromRGB(100, 125, 255)),
    ColorSequenceKeypoint.new(0.7, Color3.fromRGB(175, 90, 255)),
    ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 110, 205))
})
surface.Rotation = 15
surface.Parent = button

-- תנועה רציפה במילוי עצמו
local surfaceTween = TweenService:Create(
    surface,
    TweenInfo.new(5, Enum.EasingStyle.Linear,
        Enum.EasingDirection.InOut, -1),
    {Rotation = 375}
)
surfaceTween:Play()

local border = Instance.new("UIStroke")
border.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
border.Thickness = 3
border.Transparency = 0.05
border.Color = Color3.new(1, 1, 1)
border.Parent = button

local rainbow = Instance.new("UIGradient")
rainbow.Color = ColorSequence.new({
    ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 85, 190)),
    ColorSequenceKeypoint.new(0.25, Color3.fromRGB(145, 95, 255)),
    ColorSequenceKeypoint.new(0.5, Color3.fromRGB(65, 225, 255)),
    ColorSequenceKeypoint.new(0.75, Color3.fromRGB(100, 255, 170)),
    ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 85, 190))
})
rainbow.Parent = border

local rainbowTween = TweenService:Create(
    rainbow,
    TweenInfo.new(
        7, Enum.EasingStyle.Linear,
        Enum.EasingDirection.InOut, -1
    ),
    {Rotation = 360}
)
rainbowTween:Play()

-- השתקפות עליונה
local reflection = Instance.new("Frame")
reflection.Position = UDim2.fromOffset(18, 5)
reflection.Size = UDim2.new(1, -36, 0, 35)
reflection.BackgroundColor3 = Color3.new(1, 1, 1)
reflection.BorderSizePixel = 0
reflection.ZIndex = 2
reflection.Parent = button
corner(reflection, UDim.new(0.5, 0))

local reflectionFade = Instance.new("UIGradient")
reflectionFade.Rotation = 90
reflectionFade.Transparency = NumberSequence.new({
    NumberSequenceKeypoint.new(0, 0.55),
    NumberSequenceKeypoint.new(1, 1)
})
reflectionFade.Parent = reflection

local lightLine = Instance.new("Frame")
lightLine.Position = UDim2.new(0.5, -64, 0, 5)
lightLine.Size = UDim2.fromOffset(128, 2)
lightLine.BackgroundColor3 = Color3.new(1, 1, 1)
lightLine.BackgroundTransparency = 0.25
lightLine.BorderSizePixel = 0
lightLine.ZIndex = 3
lightLine.Parent = button
corner(lightLine, UDim.new(1, 0))

local brand = label(
    button, "S P I N   S T U D I O", 10,
    UDim2.fromOffset(20, 10),
    UDim2.fromOffset(230, 16)
)
brand.TextStrokeColor3 = Color3.fromRGB(75, 65, 140)
brand.TextStrokeTransparency = 0.65

-- אותיות שמנמנות עם שכבת עומק והברקה
local function bubbleLettering(textLabel)
    textLabel.Font = Enum.Font.LuckiestGuy
    textLabel.TextStrokeTransparency = 1
    textLabel.TextColor3 = Color3.new(1, 1, 1)

    local shadow = textLabel:Clone()
    shadow.Name = "BubbleDepth"
    shadow.Position = textLabel.Position + UDim2.fromOffset(0, 3)
    shadow.TextColor3 = Color3.fromRGB(91, 48, 157)
    shadow.TextStrokeColor3 = Color3.fromRGB(91, 48, 157)
    shadow.TextStrokeTransparency = 0
    shadow.ZIndex = textLabel.ZIndex
    shadow.Parent = textLabel.Parent
    textLabel.ZIndex = textLabel.ZIndex + 1

    local outline = Instance.new("UIStroke")
    outline.ApplyStrokeMode = Enum.ApplyStrokeMode.Contextual
    outline.Thickness = 2
    outline.Color = Color3.fromRGB(255, 245, 255)
    outline.Parent = textLabel

    local gloss = Instance.new("UIGradient")
    gloss.Rotation = 90
    gloss.Color = ColorSequence.new({
        ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 255, 255)),
        ColorSequenceKeypoint.new(0.42, Color3.fromRGB(255, 255, 255)),
        ColorSequenceKeypoint.new(0.55, Color3.fromRGB(202, 236, 255)),
        ColorSequenceKeypoint.new(1, Color3.fromRGB(245, 211, 255))
    })
    gloss.Parent = textLabel

    table.insert(connections,
        textLabel:GetPropertyChangedSignal("Text"):Connect(function()
            shadow.Text = textLabel.Text
        end)
    )
end

local title = label(
    button, "AUTO", 40,
    UDim2.fromOffset(20, 25),
    UDim2.fromOffset(230, 44)
)
title.TextStrokeColor3 = Color3.fromRGB(88, 56, 170)
title.TextStrokeTransparency = 0.15
bubbleLettering(title)

local status = label(
    button, "CLICK TO START", 12,
    UDim2.fromOffset(20, 70),
    UDim2.fromOffset(230, 18)
)
status.TextStrokeColor3 = Color3.fromRGB(65, 55, 120)
status.TextStrokeTransparency = 0.35

-- Compact health display. Does not affect the original AUTO button.
local guardStatus = label(
    button, "STABILITY: STANDBY", 10,
    UDim2.fromOffset(20, 86),
    UDim2.fromOffset(230, 12)
)
guardStatus.TextStrokeTransparency = 0.45

-- הבזק ופס ברק בתוך הכפתור
local flash = Instance.new("Frame")
flash.Size = UDim2.fromScale(1, 1)
flash.BackgroundColor3 = Color3.new(1, 1, 1)
flash.BackgroundTransparency = 1
flash.BorderSizePixel = 0
flash.ZIndex = 4
flash.Parent = button
corner(flash, UDim.new(0.5, 0))

local shine = Instance.new("Frame")
shine.AnchorPoint = Vector2.new(0.5, 0.5)
shine.Position = UDim2.fromScale(-0.25, 0.5)
shine.Size = UDim2.new(0, 65, 1, -10)
shine.BackgroundColor3 = Color3.new(1, 1, 1)
shine.BackgroundTransparency = 1
shine.BorderSizePixel = 0
shine.ZIndex = 4
shine.Parent = button
corner(shine, UDim.new(0.5, 0))

local shineFade = Instance.new("UIGradient")
shineFade.Rotation = 20
shineFade.Transparency = NumberSequence.new({
    NumberSequenceKeypoint.new(0, 1),
    NumberSequenceKeypoint.new(0.5, 0.35),
    NumberSequenceKeypoint.new(1, 1)
})
shineFade.Parent = shine

-- קונפטי מוכן מראש
local colors = {
    Color3.fromRGB(255, 90, 155),
    Color3.fromRGB(255, 220, 70),
    Color3.fromRGB(80, 240, 255),
    Color3.fromRGB(140, 255, 130),
    Color3.fromRGB(195, 130, 255),
    Color3.fromRGB(255, 255, 255)
}

local confetti = {}

for i = 1, 14 do
    local piece = Instance.new("Frame")
    piece.AnchorPoint = Vector2.new(0.5, 0.5)
    piece.Size = UDim2.fromOffset(5, 9)
    piece.BackgroundColor3 = colors[(i - 1) % #colors + 1]
    piece.BackgroundTransparency = 1
    piece.BorderSizePixel = 0
    piece.ZIndex = 6
    piece.Parent = button
    confetti[i] = piece
end

local function playEffect()
    for _, tween in ipairs(effectTweens) do
        tween:Cancel()
    end
    table.clear(effectTweens)

    local function animate(object, duration, properties)
        local tween = TweenService:Create(
            object,
            TweenInfo.new(
                duration,
                Enum.EasingStyle.Quad,
                Enum.EasingDirection.Out
            ),
            properties
        )
        table.insert(effectTweens, tween)
        tween:Play()
    end

    flash.BackgroundTransparency = 0.65
    animate(flash, 0.35, {BackgroundTransparency = 1})

    shine.Position = UDim2.fromScale(-0.25, 0.5)
    shine.BackgroundTransparency = 0
    animate(shine, 0.55, {
        Position = UDim2.fromScale(1.25, 0.5),
        BackgroundTransparency = 1
    })

    local size = button.AbsoluteSize

    for i, piece in ipairs(confetti) do
        local startX = i % 2 == 0
            and size.X * 0.18
            or size.X * 0.82

        piece.Position = UDim2.fromOffset(startX, size.Y * 0.7)
        piece.Size = UDim2.fromOffset(
            random:NextInteger(4, 7),
            random:NextInteger(6, 11)
        )
        piece.Rotation = random:NextInteger(-90, 90)
        piece.BackgroundTransparency = 0

        animate(piece, random:NextNumber(0.45, 0.75), {
            Position = UDim2.fromOffset(
                random:NextNumber(20, size.X - 20),
                random:NextNumber(8, size.Y * 0.55)
            ),
            Rotation = piece.Rotation + random:NextInteger(160, 340),
            BackgroundTransparency = 1
        })
    end
end

-- Auto-spawn and auto-equip are enabled internally.
-- Their extra GUI controls were removed as requested.

-- הודעת RGB בצורת קפסולה
local toast = Instance.new("CanvasGroup")
toast.Name = "RGBNotification"
toast.AnchorPoint = Vector2.new(0.5, 0)
toast.Position = UDim2.new(0.5, 0, 0, -70)
toast.Size = UDim2.fromOffset(280, 58)
toast.BackgroundColor3 = Color3.new(1, 1, 1)
toast.BorderSizePixel = 0
toast.GroupTransparency = 1
toast.Visible = false
toast.ZIndex = 10
toast.Parent = gui
corner(toast, UDim.new(0.5, 0))

local toastGradient = surface:Clone()
toastGradient.Parent = toast

local toastBorder = border:Clone()
toastBorder.Thickness = 2
toastBorder.Parent = toast

local toastReflection = reflection:Clone()
toastReflection.Size = UDim2.new(1, -36, 0, 22)
toastReflection.ZIndex = 11
toastReflection.Parent = toast

local toastLabel = label(
    toast, "AUTO ON", 28,
    UDim2.fromOffset(14, 0),
    UDim2.new(1, -28, 1, 0)
)
toastLabel.ZIndex = 12
-- Use exactly the same bubble lettering as the main AUTO title.
bubbleLettering(toastLabel)
-- On the moving RGB notification a darker outline is essential for contrast.
-- Keep the same white/glossy fill, with purple depth behind the letters.
toastLabel.TextSize = 34
toastLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
local toastTextOutline = toastLabel:FindFirstChildOfClass("UIStroke")
if toastTextOutline then
    toastTextOutline.Color = Color3.fromRGB(62, 28, 119)
    toastTextOutline.Thickness = 3
    toastTextOutline.Transparency = 0
end
local toastTextShadow = toast:FindFirstChild("BubbleDepth")
if toastTextShadow then
    toastTextShadow.TextSize = 34
    toastTextShadow.TextColor3 = Color3.fromRGB(62, 28, 119)
    toastTextShadow.TextStrokeColor3 = Color3.fromRGB(62, 28, 119)
    toastTextShadow.Position = toastLabel.Position + UDim2.fromOffset(0, 3)
end

local toastRGBTween = TweenService:Create(
    toastGradient,
    TweenInfo.new(4, Enum.EasingStyle.Linear,
        Enum.EasingDirection.InOut, -1),
    {Rotation = 375}
)

local toastTween
local toastVersion = 0

local function notify(text)
    toastVersion = toastVersion + 1
    local version = toastVersion

    if toastTween then toastTween:Cancel() end
    toastLabel.Text = text
    toast.Visible = true
    toastRGBTween:Play()

    toastTween = TweenService:Create(
        toast,
        TweenInfo.new(0.2, Enum.EasingStyle.Quad),
        {
            Position = UDim2.new(0.5, 0, 0, 60),
            GroupTransparency = 0
        }
    )
    toastTween:Play()

    task.delay(1.5, function()
        if not alive or version ~= toastVersion then return end

        toastTween = TweenService:Create(
            toast,
            TweenInfo.new(0.2),
            {
                Position = UDim2.new(0.5, 0, 0, 45),
                GroupTransparency = 1
            }
        )
        toastTween:Play()

        task.delay(0.22, function()
            if not alive or version ~= toastVersion then return end
            toast.Visible = false
            toastRGBTween:Pause()
        end)
    end)
end

-- גרירה ללא אנימציות מיקום
local pointer
local dragging = false
local moved = false
local pointerStart
local buttonStart

table.insert(connections, button.InputBegan:Connect(function(input)
    local kind = input.UserInputType

    if kind ~= Enum.UserInputType.MouseButton1
        and kind ~= Enum.UserInputType.Touch then
        return
    end
    if dragging then return end

    pointer = input
    dragging = true
    moved = false
    pointerStart = Vector2.new(input.Position.X, input.Position.Y)
    buttonStart = button.AbsolutePosition
end))

table.insert(connections, UserInputService.InputChanged:Connect(function(input)
    if not dragging then return end

    local mouseMove =
        pointer.UserInputType == Enum.UserInputType.MouseButton1
        and input.UserInputType == Enum.UserInputType.MouseMovement

    if not mouseMove and input ~= pointer then return end

    local position = Vector2.new(input.Position.X, input.Position.Y)
    local delta = position - pointerStart

    if delta.Magnitude >= 7 then moved = true end
    if not moved then return end

    local camera = workspace.CurrentCamera
    if not camera then return end

    local viewport = camera.ViewportSize
    local size = button.AbsoluteSize + Vector2.new(0, 202 - 100)

    button.Position = UDim2.fromOffset(
        math.clamp(
            buttonStart.X + delta.X,
            8,
            math.max(8, viewport.X - size.X - 8)
        ),
        math.clamp(
            buttonStart.Y + delta.Y,
            8,
            math.max(8, viewport.Y - size.Y - 8)
        )
    )
end))

table.insert(connections, UserInputService.InputEnded:Connect(function(input)
    if input == pointer then
        dragging = false
        pointer = nil
    end
end))

table.insert(connections, UserInputService.WindowFocusReleased:Connect(function()
    dragging = false
    pointer = nil
    moved = true
end))

-- מנגנון הסיבוב
local function setPhase(value, text)
    phase = value
    elapsed = 0
    stableTime = 0
    status.Text = text
end

local recoveryActive = false
local recoveryElapsed = 0
local recoveryStable = 0
local recoveryCooldown = 0
local recoveryPrompt
local recoveryHold = 0
local spawnAttempts = 0
local recoveryFailures = 0
local recoveryRetryAt = 0
local uiObscuredSince = nil
local uiLastClick = 0
local uiClickAttempts = 0
local recoveryG2Seen = false
local recoveryMountedSeen = false
-- V10: single placement and brief, observational settling (no hover servo).
local stageGroundY = nil
local stagePhase = "none"
local stageElapsed = 0
local stageFinalStable = 0
local lastInvokedSpawnMethod = nil
local stageAttempts = 0
local virtualInput

local function cancelRecovery()
    if recoveryPrompt then
        pcall(function() recoveryPrompt:InputHoldEnd() end)
    end
    recoveryPrompt = nil
    recoveryActive = false
    recoveryElapsed = 0
    recoveryStable = 0
    recoveryCooldown = 0
    spawnAttempts = 0
    uiClickAttempts = 0
    recoveryTravelled = false
    recoveryReturned = false
    stageGroundY = nil
    stagePhase = "none"
    stageElapsed = 0
    stageFinalStable = 0
    stageAttempts = 0
    travelAttempts = 0
    returnAttempts = 0
end

local function releaseCharacter()
    if releaseStability then releaseStability() end
    cancelRecovery()
    if root and root.Parent then
        root.AssemblyAngularVelocity = Vector3.zero
    end

    if humanoid and humanoid.Parent then
        humanoid.AutoRotate = oldAutoRotate
    end

    root = nil
    humanoid = nil
end

local function stop()
    enabled = false
    if releaseStability then releaseStability() end
    if releaseRiderLock then releaseRiderLock() end
    phase = "off"
    releaseCharacter()
    homeCFrame = nil
    title.Text = "AUTO"
    status.Text = "CLICK TO START"
end

local function heading()
    local right = root.CFrame.RightVector
    return math.atan2(-right.Z, right.X)
end

local function startCycle()
    -- Keep the same physical anchor for the whole mount, not each trick.
    if stabilityHealth then stabilityHealth() end
    baseHeight = root.Position.Y
    targetHeight = baseHeight + liftHeight
    turned = 0
    root.AssemblyAngularVelocity = Vector3.zero
    setPhase("up", "RISING")
end

local function connectCharacter()
    local character = player.Character
    local newRoot = character
        and character:FindFirstChild("HumanoidRootPart")
    local newHumanoid = character
        and character:FindFirstChildOfClass("Humanoid")

    if not newRoot or not newHumanoid
        or newHumanoid.Health <= 0 then
        return
    end

    root = newRoot
    humanoid = newHumanoid
    oldAutoRotate = humanoid.AutoRotate
    humanoid.AutoRotate = false

    fixedX = root.Position.X
    fixedZ = root.Position.Z
    -- Keep the first valid home point across accidental falls / respawns.
    -- A fresh run resets this value; restarting a character does not.
    if not homeCFrame then
        homeCFrame = root.CFrame
    end
    if newHumanoid.SeatPart then
        -- Recovery checks that this seat is our actual G2 next frame.
        startCycle()
    else
        -- Don't lift/spin the player while looking for the G2 scooter.
        setPhase("recovery", "FINDING G2")
    end
end

local function holdUpright(dt)
    local angle = heading()
    local height = root.Position.Y

    root.CFrame =
        CFrame.new(fixedX, height, fixedZ)
        * CFrame.Angles(0, angle, 0)

    local verticalSpeed = root.AssemblyLinearVelocity.Y
    -- Cap speed to the remaining distance per physics step. This allows
    -- turbo movement without overshooting the 2-stud travel repeatedly.
    local stepTime = math.max(dt, 1 / 240)

    if phase == "up" then
        verticalSpeed = math.clamp(
            (targetHeight - height) / stepTime, -riseSpeed, riseSpeed
        )
    elseif phase == "spin" then
        -- Preserve the original small stabilization while rotating.
        verticalSpeed = math.clamp(
            (targetHeight - height) * 8, -6, 6
        )
    elseif phase == "down" then
        local distanceDown = height - baseHeight
        if distanceDown > 0.16 then
            verticalSpeed = -math.min(descentSpeed, distanceDown / stepTime)
        else
            verticalSpeed = 0
        end
    end

    root.AssemblyLinearVelocity = Vector3.new(
        0, verticalSpeed, 0
    )
    root.AssemblyAngularVelocity = Vector3.new(
        0, root.AssemblyAngularVelocity.Y, 0
    )
end

local function beginLanding()
    root.AssemblyAngularVelocity = Vector3.zero
    descentObserved = false
    setPhase("down", "LANDING")
    root.AssemblyLinearVelocity = Vector3.new(
        0, -descentSpeed, 0
    )
end

-- חזרה לקורקינט של השחקן בלבד
local function childPath(parent, names)
    for _, name in ipairs(names) do
        parent = parent and parent:FindFirstChild(name)
    end
    return parent
end

local function ownRideSeat()
    return childPath(workspace, {
        "Rides", "Ride_" .. player.Name, "DriveSeat"
    })
end

-- KURKIN LIFE currently labels its G2 entry prompt "Kuki G2".
-- Accept both known display labels while still rejecting other scooter models.
local function isG2Prompt(prompt)
    return prompt ~= nil
        and prompt:IsA("ProximityPrompt")
        and (prompt.ObjectText == "G2" or prompt.ObjectText == "Kuki G2")
end

-- STABILITY GUARD (V10): resist horizontal drift without touching vertical
-- motion, spinning, collision flags, vehicle anchoring, or server ownership.
-- The original rider/anti-break logic remains intact. All objects below are
-- local, created only after a real G2 mount, and removed during recovery/OFF.
local guard = {
    root = nil, seat = nil, attachment = nil, align = nil,
    ride = nil, rideAnchor = nil, elapsed = 0, driftTime = 0, peakRideDrift = 0,
    created = 0, failure = nil, lastLog = 0,
    completed = 0, failed = 0, failedInRow = 0, lastCompletedAt = 0,
    sawSpin = false, alerted = false, idle = false
}
local GUARD_DRIFT_ALERT = 2.5  -- alert for large, sustained model movement
local GUARD_DRIFT_SECONDS = 1.5
local GUARD_LOG_EVERY = 30

stabilityHealth = function()
    guard.sawSpin = false
end

releaseStability = function()
    if guard.align then
        pcall(function() guard.align:Destroy() end)
    end
    if guard.attachment then
        pcall(function() guard.attachment:Destroy() end)
    end
    guard.root, guard.seat, guard.ride = nil, nil, nil
    guard.attachment, guard.align, guard.rideAnchor = nil, nil, nil
    guard.driftTime, guard.peakRideDrift, guard.elapsed = 0, 0, 0
end

local function setupStability(seat)
    if not root or root.Anchored or not root.Parent then return end
    releaseStability()
    guard.root, guard.seat = root, seat
    local ride = seat:FindFirstAncestorOfClass("Model")
    local rides = workspace:FindFirstChild("Rides")
    if ride and rides and ride.Parent == rides then
        guard.ride = ride
        guard.rideAnchor = ride:GetPivot().Position
    end
    guard.created = os.clock()

    -- A bounded world-space planar correction. Y-force is exactly zero,
    -- so it cannot fight the 15 studs/sec ascent/descent or jump vertically.
    -- Soft physics control avoids the repeated PivotTo feedback seen in V9.
    local attach, align
    local ok, err = pcall(function()
        attach = Instance.new("Attachment")
        attach.Name = "KL_StableXZ_Attachment"
        attach.Parent = root
        align = Instance.new("AlignPosition")
        align.Name = "KL_StableXZ_Planar"
        align.Mode = Enum.PositionAlignmentMode.OneAttachment
        align.Attachment0 = attach
        align.RigidityEnabled = false
        align.ApplyAtCenterOfMass = true
        align.ForceLimitMode = Enum.ForceLimitMode.PerAxis
        align.ForceRelativeTo = Enum.ActuatorRelativeTo.World
        local force = math.clamp(root.AssemblyMass * 380, 5000, 70000)
        align.MaxAxesForce = Vector3.new(force, 0, force)
        align.MaxVelocity = 8
        align.Responsiveness = 28
        align.Position = Vector3.new(fixedX, root.Position.Y, fixedZ)
        align.Parent = root
    end)
    if ok then
        guard.attachment, guard.align = attach, align
        guardStatus.Text = "GUARD ON | 0 SUCCESS"
        print("[KL GUARD] Horizontal stabilization active. Vertical force=0.")
    else
        if align then pcall(function() align:Destroy() end) end
        if attach then pcall(function() attach:Destroy() end) end
        guard.failure = tostring(err)
        guardStatus.Text = "GUARD FALLBACK: ROOT LOCK"
        warn("[KL GUARD] Optional planar assist unavailable; V10 root lock remains: ", err)
    end
end

maintainStability = function(dt)
    if not enabled or not root or not humanoid then
        if guard.root then releaseStability() end
        return false
    end
    local seat = ownRideSeat()
    local prompt = seat and seat:FindFirstChild("EnterPrompt")
    if recoveryActive or phase == "recovery" or not seat
        or not isG2Prompt(prompt) or humanoid.SeatPart ~= seat then
        if guard.root then releaseStability() end
        return false
    end
    if guard.root ~= root or guard.seat ~= seat then
        setupStability(seat)
    end

    -- Read the stabilized rider position after the existing rotation update.
    -- The alignment force has no effect on Y; its target follows current Y.
    if guard.align and guard.align.Parent and guard.align.Attachment0 then
        guard.align.Position = Vector3.new(fixedX, root.Position.Y, fixedZ)
    end

    guard.elapsed += dt
    if guard.elapsed < 0.2 then return false end
    local period = guard.elapsed
    guard.elapsed = 0
    if not guard.rideAnchor or not guard.ride or not guard.ride.Parent then return false end

    -- Measure actual MODEL displacement in world XZ, without confusing
    -- normal yaw/spin with translation. Do not compare world seat position
    -- to a fixed point: the seat may rotate around the scooter pivot.
    local pivot = guard.ride:GetPivot().Position
    local home = guard.rideAnchor
    local drift = (Vector2.new(pivot.X, pivot.Z)
        - Vector2.new(home.X, home.Z)).Magnitude
    guard.peakRideDrift = math.max(guard.peakRideDrift, drift)
    if drift >= GUARD_DRIFT_ALERT then
        guard.driftTime += period
    else
        guard.driftTime = 0
    end
    if guard.driftTime >= GUARD_DRIFT_SECONDS and not guard.alerted then
        guard.alerted = true
        warn(string.format("[KL GUARD] Persistent scooter model drift: %.2f studs. Check seat/physics.", drift))
        notify("G2 DRIFT DETECTED")
    end
    if guard.alerted then
        guardStatus.Text = string.format("G2 DRIFT! PEAK %.2f | OK %d", guard.peakRideDrift, guard.completed)
    else
        guardStatus.Text = string.format("GUARD %s | OK %d | MOVE %.2f", guard.align and "ON" or "FALLBACK", guard.completed, drift)
    end
    if os.clock() - guard.lastLog >= GUARD_LOG_EVERY then
        guard.lastLog = os.clock()
        print(string.format(
            "[KL GUARD] complete=%d failed=%d peak_model_drift=%.2f mounted=%s phase=%s assist=%s",
            guard.completed, guard.failed, guard.peakRideDrift,
            tostring(humanoid.SeatPart == seat), phase, tostring(guard.align ~= nil)
        ))
    end
    return false
end

-- A prolonged lack of rotations is a genuine failure; do not silently
-- report that 10 hours of useful work occurred if the game blocked spinning.
local function flagSpinFailure(reason)
    guard.failed += 1
    guard.failedInRow += 1
    warn(string.format("[KL GUARD] spin failed (%d consecutive): %s", guard.failedInRow, reason))
    if guard.failedInRow >= 3 then
        stop()
        title.Text = "ALERT"
        status.Text = "SPIN BLOCKED - CHECK"
        guardStatus.Text = string.format("0 PROGRESS | SUCCESS %d", guard.completed)
        notify("SPIN BLOCKED")
        return true
    end
    beginLanding()
    return false
end

stabilityWatchdog = function()
    -- Failed spawn/mount/recovery must not run silently for hours.
    -- Reset only after a fully measured 5300-degree spin, not on UI clicks.
    if not enabled then return false end
    if guard.lastCompletedAt > 0 and os.clock() - guard.lastCompletedAt <= 150 then
        return false
    end
    if guard.lastCompletedAt > 0 and os.clock() - guard.lastCompletedAt > 150 then
        stop()
        title.Text = "ALERT"
        status.Text = "NO COMPLETED SPIN"
        guardStatus.Text = string.format("GUARD STOPPED | OK %d", guard.completed)
        notify("AUTO STOPPED - NO SPIN")
        warn("[KL GUARD] No completed spin for 150 seconds: stopped instead of silently idling")
        return true
    end
    return false
end


local function visible(object)
    if not object then return false end
    local current = object
    while current and current ~= playerGui do
        if current:IsA("GuiObject") and not current.Visible then
            return false
        end
        if current:IsA("ScreenGui") and not current.Enabled then
            return false
        end
        current = current.Parent
    end
    return current == playerGui
end

-- SILENT G2 SPAWN: no My Rides opening, no simulated mouse movement.
-- This is a best-effort executor-dependent way to call the *existing*
-- on-click client handler. It does not invent a RemoteEvent or forge an ID.
-- Success is *only* confirmed when the server creates the G2 ride.
local function silentSpawn(button, methodIndex)
    if not button or not button:IsA("GuiButton") then
        return false, "G2 Spawn button not found"
    end

    local methods = {
        {"Activated", "connections"},
        {"MouseButton1Click", "connections"},
        {"MouseButton1Down", "connections"},
        {"Activated", "signal"},
        {"MouseButton1Click", "signal"},
        {"MouseButton1Up", "connections"}
    }

    local entry = methods[(methodIndex - 1) % #methods + 1]
    local eventName, action = entry[1], entry[2]
    local signal = button[eventName]

    if action == "signal" then
        if type(firesignal) ~= "function" then
            return false, "firesignal is unavailable in Medium"
        end
        local ok, err = pcall(firesignal, signal)
        if not ok then
            return false, eventName .. ": " .. tostring(err)
        end
        return true, "firesignal(" .. eventName .. ")"
    end

    if type(getconnections) ~= "function" then
        return false, "getconnections is unavailable in Medium"
    end

    local okConnections, results = pcall(getconnections, signal)
    if not okConnections then
        return false, "getconnections(" .. eventName .. ") failed: " .. tostring(results)
    end

    if type(results) ~= "table" or #results == 0 then
        return false, "No visible " .. eventName .. " callbacks"
    end

    -- One callback at a time so we do not double-spawn/toggle the scooter.
    -- These are executor APIs, not Roblox's supported scripting APIs.
    for _, conn in ipairs(results) do
        local okProps, active, fn, fire = pcall(function()
            return conn.Enabled, conn.Function, conn.Fire
        end)
        if okProps and active ~= false then
            if type(fn) == "function" then
                local ok, err
                if eventName == "Activated" then
                    ok, err = pcall(fn, nil, 1)
                else
                    ok, err = pcall(fn)
                end
                if ok then
                    return true, "callback(" .. eventName .. ")"
                end
                return false, "callback " .. eventName .. " failed: " .. tostring(err)
            elseif type(fire) == "function" then
                local ok, err = pcall(fire, conn)
                if ok then
                    return true, "connection.Fire(" .. eventName .. ")"
                end
                return false, "connection.Fire failed: " .. tostring(err)
            end
        end
    end
    return false, "No callable " .. eventName .. " listener"
end

local function recoveryFailure(message)
    -- A failed attempt must NOT turn AUTO OFF.
    -- Retry with a cooldown, so an obscured UI does not get spam-clicked.
    if recoveryPrompt then
        pcall(function() recoveryPrompt:InputHoldEnd() end)
    end
    recoveryPrompt = nil
    recoveryFailures += 1
    recoveryRetryAt = os.clock() + math.min(15, 3 + recoveryFailures * 2)
    recoveryActive = false
    recoveryElapsed = 0
    recoveryCooldown = 0
    travelAttempts = 0
    returnAttempts = 0
    spawnAttempts = 0
    recoveryReturned = false
    stageGroundY = nil
    stagePhase = "none"
    stageElapsed = 0
    stageFinalStable = 0
    stageAttempts = 0
    status.Text = "RECOVERY RETRY"
    warn("[AUTO RECOVERY] " .. tostring(message)
        .. " | attempt " .. recoveryFailures
        .. " | retry pending; AUTO stays ON")
end

local function moveCharacterTo(destination)
    local character = player.Character
    local transform = destination * root.CFrame:Inverse()
    character:PivotTo(transform * character:GetPivot())
    root.AssemblyLinearVelocity = Vector3.zero
    root.AssemblyAngularVelocity = Vector3.zero
end

-- Ground-aware recovery: use the actual lowest collidable scooter part,
-- not the character's original Y. This prevents the wheels from being
-- placed through the ground when the G2 is spawned elsewhere.
local FINAL_GROUND_CLEARANCE = 0.55
local INITIAL_CLEARANCE = 1.25  -- one safe placement; gravity handles descent
local SETTLE_OBSERVE = 0.30
local SETTLE_LIMIT = 1.8
local MIN_RIDE_PARTS = 15

local function getRideBottom(ride)
    local lowest = math.huge
    local collidable = 0
    for _, p in ipairs(ride:GetDescendants()) do
        if p:IsA("BasePart") and p.CanCollide then
            local frame, size = p.CFrame, p.Size
            local halfVertical = (
                math.abs(frame.RightVector.Y) * size.X
                + math.abs(frame.UpVector.Y) * size.Y
                + math.abs(frame.LookVector.Y) * size.Z
            ) * 0.5
            lowest = math.min(lowest, p.Position.Y - halfVertical)
            collidable += 1
        end
    end
    if collidable == 0 then
        -- Some vehicle games turn all collisions off temporarily.
        -- In that case use the model bounds only as a fallback.
        local frame, size = ride:GetBoundingBox()
        local halfVertical = (
            math.abs(frame.RightVector.Y) * size.X
            + math.abs(frame.UpVector.Y) * size.Y
            + math.abs(frame.LookVector.Y) * size.Z
        ) * 0.5
        lowest = frame.Position.Y - halfVertical
    end
    return lowest
end

local function raycastFloorAt(worldPos, ride)
    local params = RaycastParams.new()
    params.FilterType = Enum.RaycastFilterType.Exclude
    params.FilterDescendantsInstances = {ride, player.Character}
    params.RespectCanCollide = true
    params.IgnoreWater = true
    local highest = nil
    -- Nearby samples help avoid sinking on slightly uneven terrain.
    for _, offset in ipairs({
        Vector3.zero,
        Vector3.new(1.2, 0, 0),
        Vector3.new(-1.2, 0, 0),
        Vector3.new(0, 0, 1.2),
        Vector3.new(0, 0, -1.2)
    }) do
        local origin = worldPos + offset + Vector3.new(0, 9, 0)
        local hit = workspace:Raycast(origin, Vector3.new(0, -140, 0), params)
        if hit and (not highest or hit.Position.Y > highest) then
            highest = hit.Position.Y
        end
    end
    return highest
end

local function moveRideAndRider(ride, delta)
    if delta.Magnitude < 0.001 then return end
    local character = player.Character
    if not character or not root or not root.Parent then return end
    local beforeRoot = root.Position
    local beforeCharacterPivot = character:GetPivot()
    -- A welded rider may move together with the ride. Reposition the
    -- character only by the REMAINING displacement to avoid double-moving.
    ride:PivotTo(CFrame.new(delta) * ride:GetPivot())
    local remaining = beforeRoot + delta - root.Position
    if remaining.Magnitude > 0.03 then
        character:PivotTo(CFrame.new(remaining) * character:GetPivot())
    end
    -- Keep landing gradual and prevent old fall/spin velocity carrying over.
    local currentSeat = ownRideSeat()
    if currentSeat then
        currentSeat.AssemblyLinearVelocity = Vector3.zero
        currentSeat.AssemblyAngularVelocity = Vector3.zero
    end
    root.AssemblyLinearVelocity = Vector3.zero
    root.AssemblyAngularVelocity = Vector3.zero
end

local function returnRideHome(seat)
    local ride = childPath(workspace, {"Rides", "Ride_" .. player.Name})
    if not ride or not ride:IsA("Model") then
        return false, "Own ride model is unavailable"
    end
    if humanoid.SeatPart ~= seat or not homeCFrame then
        return false, "Mounting must be confirmed before returning"
    end
    local count = 0
    for _, item in ipairs(ride:GetDescendants()) do
        if item:IsA("BasePart") then count += 1 end
    end
    if count < MIN_RIDE_PARTS then
        return false, "G2 model has not finished loading"
    end
    local home = homeCFrame.Position
    local floorY = raycastFloorAt(home, ride)
    if not floorY then
        return false, "Could not locate solid ground at saved position"
    end
    local ok, message = pcall(function()
        local bottomY = getRideBottom(ride)
        local desiredBottomY = floorY + FINAL_GROUND_CLEARANCE + INITIAL_CLEARANCE
        local delta = Vector3.new(
            home.X - root.Position.X,
            desiredBottomY - bottomY,
            home.Z - root.Position.Z
        )
        moveRideAndRider(ride, delta)
    end)
    if ok then
        print(string.format(
            "[G2 V10] One-time placement, bottom %.2f studs above floor. Letting physics settle.",
            INITIAL_CLEARANCE + FINAL_GROUND_CLEARANCE
        ))
    end
    return ok, message, floorY
end

local function recoverRide(dt)
    local candidateSeat = ownRideSeat()
    local candidatePrompt = candidateSeat
        and candidateSeat:FindFirstChild("EnterPrompt")
    local seatIsG2 = isG2Prompt(candidatePrompt)
    -- G4 Pro may already exist: only a confirmed G2 counts as ready.
    local seat = seatIsG2 and candidateSeat or nil
    local mounted = seat and humanoid.SeatPart == seat
    if seatIsG2 and not recoveryG2Seen then
        print("[G2 DETECT] Own G2 found; EnterPrompt=" .. tostring(candidatePrompt.ObjectText))
        recoveryG2Seen = true
        -- Remember which silent input method worked for the next start.
        if environment and lastInvokedSpawnMethod then
            environment.SpinStudioG2PreferredMethod = lastInvokedSpawnMethod
            print("[G2 V10] Cached successful spawn method:", lastInvokedSpawnMethod)
        end
    elseif not seatIsG2 then
        recoveryG2Seen = false
    end
    if mounted and not recoveryMountedSeen then
        print("[G2 AUTO] G2 SEAT CONFIRMED")
        recoveryMountedSeen = true
    elseif not mounted then
        recoveryMountedSeen = false
    end

    -- A disconnected SeatPart means the rider is no longer actually seated.
    -- Remove the local retention weld BEFORE attempting to travel/reattach.
    if not mounted and releaseRiderLock then
        releaseRiderLock()
    end

    -- Manual-spawn mode: once the player is actually seated on their G2,
    -- spin must not wait for the automated spawn/recovery sequence.
    -- In particular, phase may still be "recovery" after a manual mount.
    if mounted and not autoSpawn then
        if recoveryActive then
            cancelRecovery()
        end
        recoveryFailures = 0
        recoveryRetryAt = 0
        if phase == "recovery" or phase == "off" then
            fixedX = root.Position.X
            fixedZ = root.Position.Z
            startCycle()
            print("[G2 V10 MANUAL] Manual G2 mount confirmed. Spinning started.")
        end
        return false
    end

    if mounted and not recoveryActive then
        recoveryFailures = 0
        recoveryRetryAt = 0
        return false
    end

    if not mounted and os.clock() < recoveryRetryAt then
        status.Text = "RECOVERY RETRY"
        return true
    end

    if not recoveryActive then
        recoveryActive = true
        recoveryElapsed = 0
        recoveryStable = 0
        recoveryCooldown = 0
        spawnAttempts = 0
        uiClickAttempts = 0
        recoveryTravelled = false
        recoveryReturned = false
        stageGroundY = nil
        stagePhase = "none"
        stageElapsed = 0
        stageFinalStable = 0
        stageAttempts = 0
        travelAttempts = 0
        returnAttempts = 0
        phase = "recovery"
        root.AssemblyAngularVelocity = Vector3.zero
        root.AssemblyLinearVelocity = Vector3.new(
            0, root.AssemblyLinearVelocity.Y, 0
        )
        local angle = heading()
        root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0, angle, 0)
    end

    recoveryCooldown = math.max(0, recoveryCooldown - dt)
    root.AssemblyAngularVelocity = Vector3.zero

    if mounted then
        if recoveryPrompt then
            pcall(function() recoveryPrompt:InputHoldEnd() end)
            recoveryPrompt = nil
        end

        -- Initial spawn or post-fall: ONE ground-aware placement only.
        -- Unlike V9, do not force hover height every physics frame.
        if not recoveryReturned then
            if recoveryCooldown > 0 then return true end
            if returnAttempts >= 3 then
                recoveryFailure("Could not place G2 safely")
                return true
            end
            status.Text = "POSITIONING G2"
            local ok, message, floorY = returnRideHome(seat)
            if not ok then
                returnAttempts += 1
                recoveryCooldown = 0.25
                if returnAttempts >= 3 then
                    recoveryFailure(message)
                end
                return true
            end
            returnAttempts += 1
            recoveryReturned = true
            stageGroundY = floorY
            stagePhase = "settle"
            stageElapsed = 0
            stageFinalStable = 0
            recoveryCooldown = 0.10
            print("[G2 V10] Placement complete. No repeated hover/landing teleports.")
            return true
        end

        if recoveryCooldown > 0 then return true end
        local ride = childPath(workspace, {"Rides", "Ride_" .. player.Name})
        if not ride or not seat:IsDescendantOf(ride) then
            recoveryFailure("Own G2 disappeared during seat check")
            return true
        end

        stageElapsed += dt
        status.Text = "CHECKING SEAT"
        local stillMounted = humanoid.SeatPart == seat
        local upright = root.CFrame.UpVector.Y >= 0.55
        -- Only observe clearance; never repeatedly move the ride to chase it.
        local floorGap = getRideBottom(ride) - stageGroundY
        local noGroundPenetration = floorGap >= -0.55

        if stillMounted and upright and noGroundPenetration then
            stageFinalStable += dt
        else
            stageFinalStable = 0
        end

        if stageFinalStable >= SETTLE_OBSERVE then
            fixedX = root.Position.X
            fixedZ = root.Position.Z
            cancelRecovery()
            recoveryFailures = 0
            recoveryRetryAt = 0
            notify("RIDE CONFIRMED")
            print("[G2 V10] Seat confirmed, AUTO SPIN STARTED")
            startCycle()  -- Critical: no second AUTO press required.
            return true
        end

        if stageElapsed > SETTLE_LIMIT then
            if stillMounted and noGroundPenetration and upright then
                -- Valid seat but small physics vibration: don't deadlock here.
                warn("[G2 V10] Settle timeout; seat valid. Starting spin.")
                fixedX = root.Position.X
                fixedZ = root.Position.Z
                cancelRecovery()
                recoveryFailures = 0
                recoveryRetryAt = 0
                startCycle()
            else
                -- Avoid a perpetual PivotTo loop if the server disagrees.
                recoveryFailure(string.format(
                    "Safe mount unconfirmed (mounted=%s, upright=%s, floorGap=%.2f)",
                    tostring(stillMounted), tostring(upright), floorGap
                ))
            end
        end
        return true
    end

    recoveryStable = 0

    if not autoEquip and recoveryPrompt then
        pcall(function() recoveryPrompt:InputHoldEnd() end)
        recoveryPrompt = nil
    end

    -- שתי האפשרויות כבויות: מחכה לעלייה ידנית
    if not autoSpawn and not autoEquip then
        status.Text = "MOUNT RIDE TO CONTINUE"
        recoveryElapsed = 0
        return true
    end

    -- זימון בלבד אינו מפעיל E
    if seat and not autoEquip then
        status.Text = "RIDE READY - PRESS E"
        recoveryElapsed = 0
        return true
    end

    if not seat and not autoSpawn then
        status.Text = "NO LOADED RIDE - SPAWN IT"
        recoveryElapsed = 0
        return true
    end

    recoveryElapsed = recoveryElapsed + dt
    if recoveryElapsed > 30 then
        recoveryFailure("Could not confirm recovery within 30 seconds")
        return true
    end

    if recoveryPrompt then
        recoveryHold = recoveryHold - dt
        if not recoveryPrompt.Parent or recoveryHold <= 0 then
            pcall(function() recoveryPrompt:InputHoldEnd() end)
            recoveryPrompt = nil
            recoveryCooldown = 1
        end
        return true
    end
    if recoveryCooldown > 0 then return true end

    local prompt = seat and seat:FindFirstChild("EnterPrompt")
    if autoEquip and isG2Prompt(prompt) then
        if not prompt.Enabled then
            status.Text = "WAITING FOR ENTER"
            return true
        end

        local allowedRange = math.min(10, prompt.MaxActivationDistance)
        if allowedRange <= 0 then
            recoveryFailure("Enter prompt has no usable activation range")
            return true
        end
        local distance = (seat.Position - root.Position).Magnitude
        if distance > allowedRange then
            if travelAttempts >= 3 then
                recoveryFailure("Could not reach the loaded scooter")
                return true
            end
            status.Text = "GOING TO SCOOTER"
            local offset = math.min(3, allowedRange * 0.5)
            local target = seat.Position + seat.CFrame.RightVector * offset
            target = target + Vector3.new(0, math.min(1, allowedRange * 0.2), 0)
            local ok, message = pcall(function()
                moveCharacterTo(CFrame.new(target) * CFrame.Angles(0, heading(), 0))
            end)
            if not ok then recoveryFailure(message); return true end
            travelAttempts = travelAttempts + 1
            recoveryTravelled = true
            recoveryReturned = false
            recoveryCooldown = 0.5
            return true
        end

        status.Text = "ENTERING G2"
        recoveryPrompt = prompt
        recoveryHold = prompt.HoldDuration + 0.15
        recoveryTravelled = true
        recoveryReturned = false
        local ok, message = pcall(function()
            if type(fireproximityprompt) == "function" then
                fireproximityprompt(prompt)
                print("[G2 AUTO] EnterPrompt triggered; waiting for actual seating")
                recoveryHold = 0.2
            else
                prompt:InputHoldBegin()
                print("[G2 AUTO] EnterPrompt hold started; waiting for seating")
            end
        end)
        if not ok then
            recoveryPrompt = nil
            recoveryFailure("Enter prompt could not be activated: " .. tostring(message))
        end
        return true
    end

    if seat then
        status.Text = "WAITING FOR G2 ENTER"
        return true
    end
    if not autoSpawn then return true end

    -- מוצא את כרטיס G2 לפי הכותרת המוצגת, בלי לנחש שם פנימי
    local rideList = childPath(playerGui, {
        "MainUi", "Rides", "Frame", "CanvasGroup", "ScrollingFrame"
    })
    local spawnButton
    if rideList then
        local g2 = rideList:FindFirstChild("ScooterG2")
        local knownSpawn = g2 and g2:FindFirstChild("Spawn")
        if knownSpawn and knownSpawn:IsA("GuiButton") then
            spawnButton = knownSpawn
        end
    end
    if rideList and not spawnButton then
        for _, item in ipairs(rideList:GetDescendants()) do
            if (item:IsA("TextLabel") or item:IsA("TextButton"))
                and (item.Text:match("^%s*(.-)%s*$") == "G2"
                    or item.Text:match("^%s*(.-)%s*$") == "Kuki G2") then
                local card = item.Parent
                while card and card ~= rideList do
                    local candidate = card:FindFirstChild("Spawn", true)
                    if candidate and candidate:IsA("GuiButton") then
                        spawnButton = candidate
                        break
                    end
                    card = card.Parent
                end
                if spawnButton then break end
            end
        end
    end
    -- No opening My Rides. The user may open it manually if the game
    -- requires the panel to be active, but we NEVER click or show it.
    if not spawnButton then
        status.Text = "G2 SPAWN BUTTON NOT FOUND"
        recoveryCooldown = 1
        return true
    end

    if spawnAttempts >= 6 then
        recoveryFailure("Silent spawn methods exhausted without a confirmed G2. "
            .. "See [G2 SILENT] lines; server/UI restrictions may apply.")
        return true
    end

    if os.clock() - uiLastClick < 0.90 then
        return true
    end

    local preferred = environment and environment.SpinStudioG2PreferredMethod
    local order = {}
    if type(preferred) == "number" and preferred >= 1 and preferred <= 6 then
        table.insert(order, preferred)
    end
    for i = 1, 6 do
        if i ~= preferred then table.insert(order, i) end
    end

    -- If an executor method isn't supported, immediately try the next.
    -- After any actual callback returns successfully, wait for the server
    -- to create the G2 before attempting another method.
    while spawnAttempts < 6 do
        local index = order[spawnAttempts + 1]
        spawnAttempts += 1
        local ok, message = silentSpawn(spawnButton, index)
        if ok then
            lastInvokedSpawnMethod = index
            uiLastClick = os.clock()
            recoveryCooldown = 0.90
            status.Text = "VERIFYING G2 SPAWN"
            print(string.format(
                "[G2 SILENT] Method %d/6 called: %s; waiting for G2",
                index, message
            ))
            return true
        end
        warn(string.format(
            "[G2 SILENT] Method %d unavailable: %s (immediate fallback)",
            index, message
        ))
    end

    recoveryFailure("No silent G2 spawn method is available")
    return true
end

-- RIDER LOCK: preserve the rider's attachment to the scooter seat.
-- No anchoring; no changes to spinning speed or existing Anti-Break corrections.
-- A local WeldConstraint may be overridden by the game/server; it is not
-- a guarantee of server-side seating or replication.
local riderLock = {
    seat = nil,
    humanoid = nil,
    character = nil,
    weld = nil,
    jumpAllowed = nil
}

releaseRiderLock = function()
    if riderLock.weld then
        pcall(function() riderLock.weld:Destroy() end)
    end
    if riderLock.humanoid and riderLock.humanoid.Parent then
        pcall(function()
            if riderLock.jumpAllowed ~= nil then
                riderLock.humanoid:SetStateEnabled(
                    Enum.HumanoidStateType.Jumping, riderLock.jumpAllowed
                )
            end
        end)
    end
    riderLock.seat = nil
    riderLock.humanoid = nil
    riderLock.character = nil
    riderLock.weld = nil
    riderLock.jumpAllowed = nil
end

maintainRiderLock = function()
    if not enabled then return end
    local char = player.Character
    local human = char and char:FindFirstChildOfClass("Humanoid")
    local hrp = char and char:FindFirstChild("HumanoidRootPart")
    if not human or not hrp or human.Health <= 0 then
        releaseRiderLock()
        return
    end

    if riderLock.character and riderLock.character ~= char then
        releaseRiderLock()
    end

    -- Never retain a stale weld after dismount. The recovery routine
    -- needs to move the character independently of the scooter.
    if riderLock.seat and human.SeatPart ~= riderLock.seat then
        releaseRiderLock()
    end

    -- Only attach after the player is actually sitting on their own scooter.
    if not riderLock.seat then
        local currentSeat = human.SeatPart
        local ownSeat = ownRideSeat()
        if not currentSeat or currentSeat ~= ownSeat then return end
        local enter = currentSeat:FindFirstChild("EnterPrompt")
        if not isG2Prompt(enter) then return end

        riderLock.character = char
        riderLock.humanoid = human
        riderLock.seat = currentSeat
        riderLock.jumpAllowed = human:GetStateEnabled(Enum.HumanoidStateType.Jumping)
        local weld = Instance.new("WeldConstraint")
        weld.Name = "SpinStudio_RiderLock_Local"
        weld.Part0 = currentSeat
        weld.Part1 = hrp
        weld.Parent = hrp
        riderLock.weld = weld
        human:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
        print("[SPIN+LOCK] Rider retention ON")
    end

    if riderLock.weld and not riderLock.weld.Parent then
        -- The game may remove a local constraint; don't silently claim success.
        riderLock.weld = nil
        warn("[SPIN+LOCK] Rider weld removed; cannot guarantee retention")
    end
    if human.SeatPart == riderLock.seat then
        human.Jump = false
    end
end

-- ANTI-BREAK V1: relative assembly correction (no Anchored).
-- Automatically tracks the player's scooter and restarts if it changes.
local LOCK_INTERVAL = 1 / 30
local LOCK_THRESHOLD = 3
local LOCK_MAX_GROUPS = 6
local lockState = {
    scooter = nil, seat = nil, groups = {},
    corrections = 0, peakError = 0, accumulator = 0
}

local function clearLock()
    lockState.scooter = nil
    lockState.seat = nil
    lockState.groups = {}
    lockState.accumulator = 0
end

local function frontPart(part, vehicle)
    local node = part
    while node and node ~= vehicle do
        if node.Name == "SuspensionFixed"
            or node.Name == "SuspensionGeometry"
            or node.Name == "HandGoals" then
            return true
        end
        node = node.Parent
    end
    return false
end

local function startLock()
    local char = player.Character
    local human = char and char:FindFirstChildOfClass("Humanoid")
    local currentSeat = human and human.SeatPart
    local rides = workspace:FindFirstChild("Rides")

    if not currentSeat or not rides or currentSeat ~= ownRideSeat() then return end
    local enter = currentSeat:FindFirstChild("EnterPrompt")
    if not isG2Prompt(enter) then return end

    local vehicle = currentSeat
    while vehicle and vehicle.Parent ~= rides do
        vehicle = vehicle.Parent
    end
    if not vehicle or vehicle.Parent ~= rides then return end

    if lockState.seat == currentSeat
        and lockState.scooter == vehicle then return end

    clearLock()
    lockState.seat = currentSeat
    lockState.scooter = vehicle

    local seatRoot = currentSeat.AssemblyRootPart
    local seen = {}
    for _, part in ipairs(vehicle:GetDescendants()) do
        if #lockState.groups >= LOCK_MAX_GROUPS then break end
        if part:IsA("BasePart") and frontPart(part, vehicle) then
            local assemblyRoot = part.AssemblyRootPart
            if assemblyRoot and assemblyRoot ~= seatRoot
                and assemblyRoot:IsDescendantOf(vehicle)
                and not seen[assemblyRoot] then
                seen[assemblyRoot] = true
                table.insert(lockState.groups, {
                    root = assemblyRoot,
                    offset = currentSeat.CFrame:ToObjectSpace(assemblyRoot.CFrame)
                })
            end
        end
    end
    print(string.format("[SPIN+LOCK] Saved %d assemblies", #lockState.groups))
end

-- Separate update loop: keeps the exact V1 correction policy.
table.insert(connections, RunService.Heartbeat:Connect(function(dt)
    if not alive or not enabled then return end
    -- Avoid rider weld / anti-break CFrame corrections while moving a newly
    -- spawned G2 into position. This removes the main V9 feedback loop.
    if recoveryActive or phase == "recovery" then
        clearLock()
        return
    end
    maintainRiderLock()
    if not lockState.seat
        or not lockState.seat:IsDescendantOf(lockState.scooter)
        or not player.Character
        or not player.Character:FindFirstChildOfClass("Humanoid")
        or (player.Character:FindFirstChildOfClass("Humanoid").SeatPart ~= lockState.seat
            and riderLock.seat ~= lockState.seat) then
        clearLock()
        startLock()
    end

    local currentSeat = lockState.seat
    local vehicle = lockState.scooter
    if not currentSeat or not vehicle then return end
    lockState.accumulator += dt
    if lockState.accumulator < LOCK_INTERVAL then return end
    lockState.accumulator = 0

    local seatRoot = currentSeat.AssemblyRootPart
    for _, group in ipairs(lockState.groups) do
        local assemblyRoot = group.root
        if assemblyRoot:IsDescendantOf(vehicle)
            and not assemblyRoot.Anchored
            and assemblyRoot.AssemblyRootPart == assemblyRoot
            and assemblyRoot ~= seatRoot then
            local target = currentSeat.CFrame * group.offset
            local errorDistance = (assemblyRoot.Position - target.Position).Magnitude
            lockState.peakError = math.max(lockState.peakError, errorDistance)
            if errorDistance > LOCK_THRESHOLD then
                assemblyRoot.CFrame = target
                lockState.corrections += 1
            end
        end
    end
end))

button.Activated:Connect(function(input)
    local pointerClick = not input
        or input.UserInputType == Enum.UserInputType.MouseButton1
        or input.UserInputType == Enum.UserInputType.Touch

    if pointerClick and moved then return end

    if enabled then
        stop()
        clearLock()
        notify("AUTO OFF")
    else
        enabled = true
        guard.completed, guard.failed, guard.failedInRow = 0, 0, 0
        guard.lastCompletedAt = os.clock()
        guard.alerted, guard.failure, guard.idle = false, nil, false
        guardStatus.Text = "GUARD WAITING FOR G2"
        recoveryFailures = 0
        recoveryRetryAt = 0
        startLock() -- intentionally does nothing until actually seated
        title.Text = "STOP"
        status.Text = "FINDING G2"
        lastInvokedSpawnMethod = nil
        uiLastClick = 0
        print("[G2 V10 AUTO] AUTO ON. Spawn G2, mount, then spin (G2 / Kuki G2).")
        notify("AUTO ON")
    end

    playEffect()
end)

table.insert(connections, RunService.PreSimulation:Connect(function(dt)
    if not enabled then return end

    if not root or not humanoid then
        connectCharacter()
        return
    end

    if not root.Parent or not humanoid.Parent
        or humanoid.Health <= 0
        or root.Parent ~= player.Character then

        releaseCharacter()
        status.Text = "WAITING FOR CHARACTER"
        return
    end

    if recoverRide(dt) then
        if releaseStability then releaseStability() end
        return
    end

    if maintainStability then maintainStability(dt) end
    elapsed = elapsed + dt
    local verticalVelocity = root.AssemblyLinearVelocity.Y
    holdUpright(dt)

    if phase == "up" then
        root.AssemblyAngularVelocity = Vector3.zero

        if math.abs(root.Position.Y - targetHeight) < 0.3 then
            turned = 0
            previousAngle = heading()
            setPhase("spin", "SPINNING")
        elseif elapsed > 5 then
            beginLanding()
        end

    elseif phase == "spin" then
        local angle = heading()
        local difference = angle - previousAngle
        local delta = math.atan2(
            math.sin(difference),
            math.cos(difference)
        )

        turned = turned + math.deg(delta)
        previousAngle = angle
        local remaining = targetDegrees - turned

        status.Text = string.format(
            "%.0f / %d", turned, targetDegrees
        )

        if math.abs(turned) >= 60 then guard.sawSpin = true end
        if remaining <= 0.1 then
            guard.completed += 1
            guard.lastCompletedAt = os.clock()
            guard.failedInRow = 0
            guard.sawSpin = false
            beginLanding()
            return
        end
        if (elapsed >= 4 and not guard.sawSpin) or elapsed > 15 then
            flagSpinFailure(elapsed > 15 and "15s spin timeout" or "no measured yaw after 4s")
            return
        end

        local stepTime = math.max(dt, 1 / 240)
        local speed = math.min(
            maxSpeed,
            remaining * finishResponse,
            remaining / stepTime,
            90 / stepTime
        )

        root.AssemblyAngularVelocity = Vector3.new(
            0, math.rad(speed), 0
        )

    elseif phase == "down" then
        root.AssemblyAngularVelocity = Vector3.zero

        -- With turbo descent, touchdown can happen in 1-2 physics steps.
        -- The old 0.15-second settle detection slowed every loop considerably.
        if root.Position.Y <= baseHeight + 0.24 then
            root.AssemblyLinearVelocity = Vector3.zero
            setPhase("wait", "NEXT ROUND")
        else
            if verticalVelocity < -2 then
                descentObserved = true
            end
            -- Backup: ground collision may stop us a little above baseHeight.
            if math.abs(verticalVelocity) < 1
                and (descentObserved or elapsed >= 0.06) then
                stableTime = stableTime + dt
            else
                stableTime = 0
            end

            if stableTime >= 0.03 then
                root.AssemblyLinearVelocity = Vector3.zero
                setPhase("wait", "NEXT ROUND")
            elseif elapsed > 3 then
                setPhase("wait", "RETRYING")
            end
        end

    elseif phase == "wait" then
        root.AssemblyAngularVelocity = Vector3.zero

        if elapsed >= waitTime then
            startCycle()
        end
    end
end))

table.insert(connections, player.CharacterRemoving:Connect(function()
    releaseRiderLock()
    releaseCharacter()

    if enabled then
        status.Text = "WAITING FOR CHARACTER"
    end
end))

table.insert(connections, player.Idled:Connect(function(seconds)
    if not enabled or guard.idle then return end
    guard.idle = true
    warn(string.format("[KL GUARD] Roblox idle for %.0f seconds; idle disconnect may stop long sessions.", seconds))
    notify("ROBLOX IDLE WARNING")
end))

-- V6: loading the script only builds the GUI. No spawn, equip or spinning yet.
-- Only a real press on the original AUTO button switches `enabled` to true.
print("[SPIN STUDIO V10] READY / AUTO OFF")
print("[SPIN STUDIO V10] Press AUTO to auto-spawn G2, auto-mount, and spin.")

gui.Destroying:Connect(function()
    alive = false
    toastVersion = toastVersion + 1
    stop()
    clearLock()
    print("[SPIN+LOCK] Corrections:", lockState.corrections,
        "Peak error:", lockState.peakError)
    rainbowTween:Cancel()
    surfaceTween:Cancel()
    toastRGBTween:Cancel()

    if toastTween then toastTween:Cancel() end

    for _, tween in ipairs(effectTweens) do
        tween:Cancel()
    end

    for _, connection in ipairs(connections) do
        connection:Disconnect()
    end
end)
Executor compatibility changes over time. Check current reports before testing.

Updated and tested for the latest Auto Wheelie Update, this script automates the newest event tasks so you can keep up without the extra grind.

Copy the code above into a compatible Roblox script executor if you choose to test it.

Kukirin Life Script Status

✓AvailabilityFree
$Price$0
◫CompatibilityDesktop & Mobile
★SafetyVerified

Roblox and game updates can affect compatibility, so the script’s status should be treated as temporary rather than guaranteed.

What Is a Kukirin Life Script?

A Kukirin Life script is Lua code intended to run alongside the Roblox game through a third-party script executor.

Different scripts can contain different code and features. This version includes the following features:

✓ Auto Ride✓ Ride Failsafe✓ Scooter Mods✓ Wheelie Assist✓ Auto Buy✓ Auto Hardware✓ Auto Claim Rewards✓ Unlock Items✓ Teleport✓ Walk Speed✓ Fly

How to Use the Kukirin Life Script

If you decide to test a third-party Roblox script, the general process involves a compatible executor and the Lua code provided above.

01
Choose a Roblox Script Executor
Pick a compatible executor such as Hydrogen, MacSploit, AWP.GG, Delta, Fluxus, Codex. Compatibility changes over time, so a name here doesn’t guarantee current support.
02
Open Roblox and Join the Game
Launch Roblox, join the game, and keep it open while you prepare the executor.
03
Copy the Lua Script
Copy the complete code from the script card above without changing any part of it.
04
Run Your Executor
Open your executor and paste the code into its editor.
05
Execute the Script
Click Run or Execute. If the script still supports the current game version, it should load.

Can a Kukirin Life Script Get Your Roblox Account Banned?

⚠️ Yes, it can. Third-party scripts can violate Roblox rules and may put an account at risk.
  • Only use code from a source you trust.
  • Never enter your Roblox password into a script or executor.
  • Test on an alternate account first.

Kukirin Life Script for Mobile

If you’re searching for a Kukirin Life script for mobile, check whether both the executor and the script support your device and current Roblox version. Mobile executor support does not guarantee that every script will work.

Frequently Asked Questions

What is a Kukirin Life script?

A Kukirin Life script is third-party Lua code intended to run alongside the Roblox game through a compatible script executor.

What features does this Kukirin Life script include?

Different scripts contain different code. This version includes: Auto Farm, ESP, Teleport, Speed Boost, Fly, Noclip, Auto Quest, Auto Buy, Anti-AFK, Stability Guard, 775°/S, Fast Rise, Advanced Stability Guard, Automatic G2 Scooter Spawn, Continuous Spin Cycles, Simple ON/OFF Control, Optimized For Smooth, Stable Spinning, Stability, Automation.

How do you use the Kukirin Life script?

Pick a compatible executor such as Hydrogen, MacSploit, AWP.GG, Delta, Fluxus, Codex, launch Roblox and join the game, copy the complete Lua code from the script card above, paste it into the executor’s editor, and click Run or Execute. Compatibility changes over time, so a name here doesn’t guarantee current support.

Can a Kukirin Life script get your Roblox account banned?

Yes. Third-party scripts can violate Roblox rules and may put an account at risk. Only use code from a source you trust, never enter your Roblox password into a script or executor, and test on an alternate account first.

Does the Kukirin Life script work on mobile?

Check whether both the executor and the script support your device and the current Roblox version. Mobile executor support does not guarantee that every script will work.

Check out our Roblox Scripts hub and Roblox Games Directory for more.