CCCPaste

Obby But You’re On a Bike: Auto-Complete GUI

--[[
    Obby But You’re On a Bike: Auto-Complete GUI
    Original (non-GUI): https://pastebin.com/W1YPeqEU

    by darraghd493
]]

local function loadLibrary(url)
	local success, result = pcall(function()
		return loadstring(game:HttpGet(url))()
	end)
	if success then
		return result
	else
		error("Failed to load library from " .. url .. ": " .. tostring(result))
	end
end

getgenv().OBYOAB_Settings = { -- Lazy solution for settings storage
    AUTO_COMPLETE = false,
    AUTO_RESET = false,
    AUTO_RESET_DELAY = 30,
    AUTO_RESET_DELAY_RANDOMISATION = 5,
}

--#region UI
local Rayfield = loadLibrary("https://raw.githubusercontent.com/SiriusSoftwareLtd/Rayfield/main/source.lua")
local Window = Rayfield:CreateWindow({
	Name = "Obby But You’re On a Bike",
	LoadingTitle = "Obby But You’re On a Bike",
	LoadingSubtitle = "by dd493",
	ConfigurationSaving = {
		Enabled = false,
	},
	KeySystem = false,
})
local AutoFarmTab = Window:CreateTab("Auto-Farm", "gamepad")
AutoFarmTab:CreateSection("Auto-Complete")
AutoFarmTab:CreateToggle({
    Name = "Active",
    CurrentValue = getgenv().OBYOAB_Settings.AUTO_COMPLETE,
    Flag = "AutoCompleteActive",
    Callback = function(value)
        getgenv().OBYOAB_Settings.AUTO_COMPLETE = value
    end,
})
AutoFarmTab:CreateSection("Auto-Reset (for Worlds/Normal)")
AutoFarmTab:CreateToggle({
    Name = "Active",
    CurrentValue = getgenv().OBYOAB_Settings.AUTO_RESET,
    Flag = "AutoResetActive",
    Callback = function(value)
        getgenv().OBYOAB_Settings.AUTO_RESET = value
    end,
})
AutoFarmTab:CreateSlider({
    Name = "Delay (seconds)",
    Range = {0, 120},
    Increment = 1,
    Suffix = "seconds",
    CurrentValue = getgenv().OBYOAB_Settings.AUTO_RESET_DELAY,
    Flag = "AutoResetDelay",
    Callback = function(value)
        getgenv().OBYOAB_Settings.AUTO_RESET_DELAY = value
    end,
})
AutoFarmTab:CreateSlider({
    Name = "Delay Randomisation (seconds)",
    Range = {0, 30},
    Increment = 1,
    Suffix = "seconds",
    CurrentValue = getgenv().OBYOAB_Settings.AUTO_RESET_DELAY_RANDOMISATION,
    Flag = "AutoResetDelayRandomisation",
    Callback = function(value)
        getgenv().OBYOAB_Settings.AUTO_RESET_DELAY_RANDOMISATION = value
    end,
})
--#endregion

--#region Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace") 
local Players = game:GetService("Players")

local LocalPlayer = Players.LocalPlayer

local RemoteEvents = ReplicatedStorage:WaitForChild("RemoteEvents")
local NotificationRemote = RemoteEvents:FindFirstChild("Notification")
local ReportResetRemote = RemoteEvents:FindFirstChild("ReportReset")

for _, connection in getconnections(NotificationRemote.OnClientEvent) do
    local old; old = hookfunction(connection.Function, function(text, ...)
        -- does text contain "beat"?
        if string.find(string.lower(text), "beat") and getgenv().OBYOAB_Settings.AUTO_RESET then
            if getgenv().OBYOAB_Settings.AUTO_COMPLETE and getgenv().OBYOAB_Settings.AUTO_RESET then
                task.delay(getgenv().OBYOAB_Settings.AUTO_RESET_DELAY + math.random(0, getgenv().OBYOAB_Settings.AUTO_RESET_DELAY_RANDOMISATION), function()
                    ReportResetRemote:FireServer()
                end)
            end
            return
        end
        return old(text, ...)
    end)
end

while task.wait() do
    if not getgenv().OBYOAB_Settings.AUTO_COMPLETE then
        continue
    end

    local checkpoints = Workspace:WaitForChild("WorldMap"):WaitForChild("Checkpoints")
    local endCheckpoint = checkpoints[#checkpoints:GetChildren()]

    -- be safe, this is an autofarm after all xD
    local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

    repeat RunService.Heartbeat:Wait() until endCheckpoint:FindFirstChild("Hitbox")
    repeat RunService.Heartbeat:Wait() until endCheckpoint.Hitbox:FindFirstChild("TouchInterest")

    firetouchinterest(endCheckpoint.Hitbox, humanoidRootPart, true)
    firetouchinterest(endCheckpoint.Hitbox, humanoidRootPart, false)
    
    RunService.Heartbeat:Wait()
end
--#endregion