local typeof_ = (type(typeof) == "function" and typeof) or type local now = (type(time) == "function" and time) or os.clock local getconnections_ = getconnections local getgenv_ = getgenv local shared_ = shared local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local registry = (type(getgenv_) == "function" and getgenv_()) or (type(shared_) == "table" and shared_) or _G local KEY = "__Split_AutoTrick_Controller_v1__" local existing = registry[KEY] if type(existing) == "table" and type(existing.IsInstalled) == "function" and existing.IsInstalled() then existing.SetEnabled(true) return existing end local settings = { Cooldown = 1.1, ReleaseDelay = 0.05, ResolveRetry = 0.25, ErrorRetry = 0.5, } local enabled, installed = true, false local unavailable = nil local lastTrick = -math.huge local nextAt = { sprinting = 0, actors = 0, trick = 0 } local cache = { sprinting = nil, actors = nil, button = nil, down = nil, up = nil } local heartbeat = nil local warned = {} local function warnOnce(key, message) if warned[key] then return end warned[key] = true print("[auto_trick] " .. key .. ": " .. tostring(message)) end local function child(parent, name) if not parent then return nil end return parent:FindFirstChild(name) end local function safeRequire(module) local ok, value = pcall(require, module) if not ok or type(value) ~= "table" then return nil, tostring(value) end return value end local function resolveSprinting(t) if cache.sprinting then return cache.sprinting end if t < nextAt.sprinting then return nil end local systems = child(ReplicatedStorage, "Systems") local character = child(systems, "Character") local gameplay = child(character, "Game") local module = child(gameplay, "Sprinting") if not module then nextAt.sprinting = t + settings.ResolveRetry return nil end local value, err = safeRequire(module) if not value then nextAt.sprinting = t + settings.ErrorRetry warnOnce("sprinting", "Sprinting require failed: " .. tostring(err)) return nil end cache.sprinting = value return value end local function resolveActors(t) if cache.actors then return cache.actors end if t < nextAt.actors then return nil end local modules = child(ReplicatedStorage, "Modules") local gameplay = child(modules, "Gameplay") local module = child(gameplay, "Actors") if not module then nextAt.actors = t + settings.ResolveRetry return nil end local value, err = safeRequire(module) if not value then nextAt.actors = t + settings.ErrorRetry warnOnce("actors", "Actors require failed: " .. tostring(err)) return nil end cache.actors = value return value end local function active() return enabled and installed end local function fire(signal) if not signal or type(getconnections_) ~= "function" then return end for _, connection in pairs(getconnections_(signal)) do if connection and connection.Connected ~= false and connection.Enabled ~= false then if type(connection.Fire) == "function" then pcall(connection.Fire, connection) elseif type(connection.Function) == "function" then pcall(connection.Function) end end end end local function release(sprinting, button) pcall(function() if not active() then return end if sprinting.MobileButton ~= button then return end fire(cache.up) end) end local function tryTrick(t) local sprinting = resolveSprinting(t) local actors = resolveActors(t) if not sprinting or not actors then return end local button = sprinting.MobileButton if not button or not button.Parent then nextAt.trick = t + settings.ResolveRetry return end if cache.button ~= button then cache.button = button cache.down = button.MouseButton1Down cache.up = button.MouseButton1Up end local actor = actors.CurrentActors and actors.CurrentActors[player] if not actor or not actor.State or not actor.State.isSkating then return end local highlight = actor.Instances and actor.Instances.Sk8Highlight if not highlight or not highlight.Adornee then return end lastTrick = t fire(cache.down) task.delay(settings.ReleaseDelay, release, sprinting, button) end local controller = { Settings = settings } function controller.IsEnabled() return enabled end function controller.IsInstalled() return installed end function controller.SetEnabled(value) enabled = not not value if not enabled then lastTrick = -math.huge end end function controller.SetCooldown(value) assert(typeof_(value) == "number" and value > 0, "cooldown must be > 0") settings.Cooldown = value end function controller.Status() return { Installed = installed, Enabled = enabled, Unavailable = unavailable, Cooldown = settings.Cooldown, ReleaseDelay = settings.ReleaseDelay, Modules = { Sprinting = cache.sprinting ~= nil, Actors = cache.actors ~= nil, }, } end function controller.Stop() installed = false enabled = false unavailable = nil if heartbeat then heartbeat:Disconnect() heartbeat = nil end lastTrick = -math.huge nextAt.sprinting, nextAt.actors, nextAt.trick = 0, 0, 0 cache.sprinting, cache.actors = nil, nil cache.button, cache.down, cache.up = nil, nil, nil registry[KEY] = nil end function controller.Restart() if installed then return true end enabled = true lastTrick = -math.huge return controller._install() end function controller._install() if type(getconnections_) ~= "function" then unavailable = "getconnections unavailable" warnOnce("autotrick", unavailable) else heartbeat = RunService.Heartbeat:Connect(function() if not active() then return end local t = now() if t - lastTrick < settings.Cooldown then return end if t < nextAt.trick then return end local ok, failure = pcall(tryTrick, t) if not ok then nextAt.trick = t + settings.ErrorRetry lastTrick = t - settings.Cooldown warnOnce("autotrick", "trick failed: " .. tostring(failure)) end end) unavailable = nil end installed = true registry[KEY] = controller return true end assert(controller._install(), "failed to install auto trick") return controller