explore
key systems
new
docs
discord
search scripts
⌘K
explore
key systems
new
docs
discord
sign in
⌘↵
--
publishes from anywhere on this page
new paste
untitled.luau
empty
/ 512kb
open file
⌘O
explore
key systems
new
docs
sign in
function-lua-copy.luau
1613 lines · 43.1kb
/ 512kb
open file
⌘O
-- FunctionFramework v3 (Roblox) -- Semua pencarian (path, nama, class, attribute, player, tool, remote) TIDAK peka huruf besar/kecil. -- "world1.tower.pad" = "World1.Tower.Pad" = "WORLD1.tower.PAD" -- -- local fc = loadstring(game:HttpGet("URL_RAW_KAMU"))() -- local inst, path = fc.findPath("world1.tower.pad") -- print(path) --> workspace.Maps.World1.Tower.Folder.Pad -- -- Tiap bagian path dicari di mana pun di dalam bagian sebelumnya. -- Hasil pencarian disimpan di cache supaya pencarian berikutnya instan. -- Nama fungsi juga tidak peka huruf: fc.findPath == fc.FindPath local FC = {} FC.version = 3 -- ============================================ -- SERVICES -- ============================================ local Players = game:GetService("Players") local RunService = game:GetService("RunService") local TweenService = game:GetService("TweenService") local HttpService = game:GetService("HttpService") local LP = Players.LocalPlayer FC.LocalPlayer = LP local function isInst(x) return typeof(x) == "Instance" end local function lower(x) return tostring(x):lower() end -- Lokasi yang dipindai saat mencari berdasarkan nama local SEARCH_ROOTS = { workspace, game:GetService("ReplicatedStorage"), game:GetService("Players"), game:GetService("Lighting"), game:GetService("StarterGui"), game:GetService("StarterPack"), game:GetService("ReplicatedFirst"), } local function toPath(inst) local full = inst:GetFullName() return (full:gsub("^Workspace", "workspace")) end -- Cek class tanpa peduli huruf besar/kecil ("basepart" = "BasePart") local function classOk(inst, class) if not class then return true end local ok, res = pcall(inst.IsA, inst, class) if ok and res then return true end local ok2, res2 = pcall(inst.IsA, inst, class:sub(1, 1):upper() .. class:sub(2)) if ok2 and res2 then return true end return inst.ClassName:lower() == lower(class) end -- Cari attribute tanpa peduli huruf besar/kecil, kembalikan nama asli local function realAttrName(inst, name) if inst:GetAttribute(name) ~= nil then return name end local low = lower(name) for k in pairs(inst:GetAttributes()) do if k:lower() == low then return k end end return nil end -- ============================================ -- 1. UTIL DASAR -- ============================================ function FC.safe(fn, ...) local r = table.pack(pcall(fn, ...)) if r[1] then return true, table.unpack(r, 2, r.n) end return false, r[2] end function FC.retry(fn, times, delay) times = times or 3 delay = delay or 0.3 local lastErr for _ = 1, times do local ok, res = pcall(fn) if ok and res ~= nil and res ~= false then return res end lastErr = res task.wait(delay) end return nil, lastErr end function FC.waitFor(cond, timeout, step) timeout = timeout or 10 step = step or 0.1 local t0 = os.clock() while os.clock() - t0 < timeout do local ok, res = pcall(cond) if ok and res then return res end task.wait(step) end return nil end function FC.debounce(fn, wait) wait = wait or 0.3 local last = 0 return function(...) local now = os.clock() if now - last >= wait then last = now return fn(...) end end end function FC.loop(fn, interval) interval = interval or 0.1 local running = true task.spawn(function() while running do pcall(fn) task.wait(interval) end end) return function() running = false end end -- ============================================ -- 2. STRING -- ============================================ function FC.split(str, sep) local out = {} if type(str) ~= "string" then return out end sep = sep or "." local pattern = "([^" .. sep:gsub("%p", "%%%0") .. "]+)" for part in string.gmatch(str, pattern) do table.insert(out, part) end return out end function FC.trim(str) local s = tostring(str):gsub("^%s+", "") s = s:gsub("%s+$", "") return s end function FC.contains(str, sub, caseSensitive) str, sub = tostring(str), tostring(sub) if not caseSensitive then str, sub = str:lower(), sub:lower() end return str:find(sub, 1, true) ~= nil end function FC.startsWith(str, prefix) return lower(str):sub(1, #prefix) == lower(prefix) end function FC.endsWith(str, suffix) return suffix == "" or lower(str):sub(-#suffix) == lower(suffix) end function FC.formatNumber(n) n = tonumber(n) if not n then return "0" end local s = tostring(math.floor(n)) local rev = s:reverse():gsub("(%d%d%d)", "%1,") local out = rev:reverse() out = out:gsub("^,", "") return out end function FC.parseNumber(str) if type(str) == "number" then return str end local s = tostring(str):lower():gsub(",", "") s = s:gsub("%s+", "") local num, suffix = s:match("^([%d%.]+)(%a*)$") num = tonumber(num) if not num then return nil end local mult = {k = 1e3, m = 1e6, b = 1e9, t = 1e12} return num * (mult[suffix] or 1) end -- ============================================ -- 3. PATH & FIND (SEMUA LOWERCASE) -- ============================================ local pathCache = {} function FC.clearCache() pathCache = {} end -- Anak langsung dengan nama (abaikan huruf besar/kecil) local function childLower(parent, lowName) for _, c in ipairs(parent:GetChildren()) do if c.Name:lower() == lowName then return c end end return nil end local function strictChild(parent, lowName) if parent == game then if lowName == "workspace" then return workspace end for _, svc in ipairs(game:GetChildren()) do if svc.Name:lower() == lowName then return svc end end return nil end return childLower(parent, lowName) end -- Path lengkap persis dari root (cepat) local function strictResolve(parts, start) local current = start or game for _, part in ipairs(parts) do current = strictChild(current, part) if not current then return nil end end return current end -- Kandidat: anak langsung dulu, lalu semua keturunan local function candidates(parent, lowName) local list, deep = {}, {} for _, c in ipairs(parent:GetChildren()) do if c.Name:lower() == lowName then table.insert(list, c) end end for _, d in ipairs(parent:GetDescendants()) do if d.Parent ~= parent and d.Name:lower() == lowName then table.insert(deep, d) end end for _, d in ipairs(deep) do table.insert(list, d) end return list end -- Telusuri bagian path berikutnya (dengan backtracking) local function resolveDeep(parent, parts, idx, results, limit, class) for _, cand in ipairs(candidates(parent, parts[idx])) do if idx == #parts then if classOk(cand, class) then table.insert(results, cand) if #results >= limit then return true end end else if resolveDeep(cand, parts, idx + 1, results, limit, class) then return true end end end return false end local function smartFind(parts, roots, limit, class) local results = {} for _, root in ipairs(roots) do if root then local first = {} if root.Name:lower() == parts[1] or (root == workspace and parts[1] == "workspace") then table.insert(first, root) end for _, c in ipairs(candidates(root, parts[1])) do table.insert(first, c) end for _, cand in ipairs(first) do if #parts == 1 then if classOk(cand, class) then table.insert(results, cand) end else resolveDeep(cand, parts, 2, results, limit, class) end if #results >= limit then return results end end end end return results end -- Pecah path jadi bagian huruf kecil local function parsePath(path) local sep = path:find("/", 1, true) and "/" or "." local parts = FC.split(path:lower(), sep) if #parts > 1 and parts[1] == "game" then table.remove(parts, 1) end return parts end local function parseArgs(arg2) if isInst(arg2) then return {root = arg2} end if type(arg2) == "table" then return arg2 end return {} end local function getRoots(opts) if opts.root then local r = isInst(opts.root) and opts.root or FC.findPath(opts.root) return r and {r} or {} end return SEARCH_ROOTS end -- findPath("world1.tower.pad") -> instance, "workspace.Maps.World1.Tower.Pad" -- opts: {root=..., class="model", strict=true, nocache=true} function FC.findPath(path, arg2) if isInst(path) then return path, toPath(path) end if type(path) ~= "string" or path == "" then return nil end local opts = parseArgs(arg2) local parts = parsePath(path) if #parts == 0 then return nil end -- cache local rootKey = isInst(opts.root) and opts.root:GetDebugId() or tostring(opts.root or "") local key = table.concat(parts, ".") .. "|" .. rootKey .. "|" .. lower(opts.class or "") .. (opts.strict and "|s" or "") local cached = pathCache[key] if cached and not opts.nocache then if cached.Parent ~= nil and cached:IsDescendantOf(game) then return cached, toPath(cached) end pathCache[key] = nil end local found -- 1) path lengkap (cepat) local start = isInst(opts.root) and opts.root or nil local strict = strictResolve(parts, start) if strict and classOk(strict, opts.class) then found = strict end -- 2) pencarian pintar if not found and not opts.strict then found = smartFind(parts, getRoots(opts), 1, opts.class)[1] end if found then pathCache[key] = found return found, toPath(found) end return nil end -- Semua hasil yang cocok -> list path (string), list instance function FC.findPaths(path, arg2) if type(path) ~= "string" or path == "" then return {}, {} end local opts = parseArgs(arg2) local parts = parsePath(path) if #parts == 0 then return {}, {} end local results = smartFind(parts, getRoots(opts), opts.limit or 200, opts.class) local paths = {} for i, inst in ipairs(results) do paths[i] = toPath(inst) end return paths, results end -- Cari berdasarkan satu nama (huruf kecil). exact=false -> nama mengandung kata function FC.searchPath(name, opts) opts = opts or {} local q = lower(name) for _, root in ipairs(getRoots(opts)) do if root then for _, d in ipairs(root:GetDescendants()) do local n = d.Name:lower() local hit if opts.exact == false then hit = n:find(q, 1, true) ~= nil else hit = n == q end if hit and classOk(d, opts.class) then return toPath(d), d end end end end return nil end function FC.searchPaths(name, opts) opts = opts or {} local q = lower(name) local out, insts = {}, {} for _, root in ipairs(getRoots(opts)) do if root then for _, d in ipairs(root:GetDescendants()) do local n = d.Name:lower() local hit if opts.exact == false then hit = n:find(q, 1, true) ~= nil else hit = n == q end if hit and classOk(d, opts.class) then table.insert(out, toPath(d)) table.insert(insts, d) end end end end return out, insts end function FC.getPath(inst) if not isInst(inst) then return nil end return toPath(inst) end function FC.exists(x) local i = FC.findPath(x) return i ~= nil and i.Parent ~= nil end function FC.waitPath(path, timeout) return FC.waitFor(function() return (FC.findPath(path, {nocache = true})) end, timeout or 10, 0.5) end function FC.findFirst(name, root, recursive) root = (root and FC.findPath(root)) or game local q = lower(name) local c = childLower(root, q) if c then return c end if recursive ~= false then for _, d in ipairs(root:GetDescendants()) do if d.Name:lower() == q then return d end end end return nil end function FC.findByClass(className, root) root = (root and FC.findPath(root)) or workspace local out = {} for _, d in ipairs(root:GetDescendants()) do if classOk(d, className) then table.insert(out, d) end end return out end function FC.findAncestor(inst, name) if not isInst(inst) then return nil end local q = lower(name) local p = inst.Parent while p do if p.Name:lower() == q then return p end p = p.Parent end return nil end function FC.findAncestorOfClass(inst, className) if not isInst(inst) then return nil end local p = inst.Parent while p do if classOk(p, className) then return p end p = p.Parent end return nil end -- findAll{ root=, name=, class=, text=, attr=, exact=, limit=, filter=fn } function FC.findAll(opts) opts = opts or {} local root = (opts.root and FC.findPath(opts.root)) or workspace local limit = opts.limit or math.huge local name = opts.name and lower(opts.name) local text = opts.text and lower(opts.text) local attr = opts.attr and lower(opts.attr) local out = {} for _, d in ipairs(root:GetDescendants()) do if #out >= limit then break end local ok = true if ok and opts.class and not classOk(d, opts.class) then ok = false end if ok and name then local n = d.Name:lower() if opts.exact then ok = (n == name) else ok = n:find(name, 1, true) ~= nil end end if ok and text then local found = false if d:IsA("TextLabel") or d:IsA("TextButton") or d:IsA("TextBox") then found = d.Text:lower():find(text, 1, true) ~= nil end ok = found end if ok and attr then ok = realAttrName(d, attr) ~= nil end if ok and opts.filter then local s, r = pcall(opts.filter, d) ok = s and r and true or false end if ok then table.insert(out, d) end end return out end function FC.findByText(text, root) return FC.findAll({root = root, text = text}) end function FC.findByAttribute(attr, root) return FC.findAll({root = root, attr = attr}) end function FC.children(inst, className) inst = FC.findPath(inst) if not inst then return {} end if not className then return inst:GetChildren() end local out = {} for _, c in ipairs(inst:GetChildren()) do if classOk(c, className) then table.insert(out, c) end end return out end function FC.countChildren(inst, className) return #FC.children(inst, className) end function FC.findParentWithChildren(inst, minCount, maxDepth) local cur, depth = inst, 0 while cur and depth < (maxDepth or 20) do local n = 0 for _, c in ipairs(cur:GetChildren()) do if c:IsA("BasePart") or c:IsA("Model") then n += 1 end end if n >= (minCount or 10) then return cur end cur = cur.Parent depth += 1 end return nil end -- ============================================ -- 4. VALUE / PROPERTY / ATTRIBUTE -- ============================================ function FC.getProp(inst, prop) inst = FC.findPath(inst) if not inst then return nil end local ok, v = pcall(function() return inst[prop] end) if ok then return v end local pascal = tostring(prop):sub(1, 1):upper() .. tostring(prop):sub(2) ok, v = pcall(function() return inst[pascal] end) if ok then return v end return nil end function FC.setProp(inst, prop, value) inst = FC.findPath(inst) if not inst then return false end if pcall(function() inst[prop] = value end) then return true end local pascal = tostring(prop):sub(1, 1):upper() .. tostring(prop):sub(2) return (pcall(function() inst[pascal] = value end)) end function FC.getAttr(inst, name) inst = FC.findPath(inst) if not inst then return nil end local real = realAttrName(inst, name) return real and inst:GetAttribute(real) or nil end function FC.setAttr(inst, name, value) inst = FC.findPath(inst) if not inst then return false end local real = realAttrName(inst, name) or name return (pcall(inst.SetAttribute, inst, real, value)) end function FC.getAttrs(inst) inst = FC.findPath(inst) return inst and inst:GetAttributes() or {} end -- getValue("config.speed") -> ValueBase.Value / Text -- getValue("world1.door@health") -> attribute (huruf bebas) function FC.getValue(target, default) if type(target) == "string" then local p, attr = target:match("^(.-)@(.+)$") if p then local i = FC.findPath(p) local real = i and realAttrName(i, attr) local v = real and i:GetAttribute(real) if v == nil then return default end return v end end local inst = FC.findPath(target) if not inst then return default end if inst:IsA("ValueBase") then return inst.Value end if inst:IsA("TextLabel") or inst:IsA("TextButton") or inst:IsA("TextBox") then return inst.Text end if inst:IsA("ProximityPrompt") then return inst.ActionText end if inst:IsA("Humanoid") then return inst.Health end return default end function FC.setValue(target, value) local inst = FC.findPath(target) if not inst then return false end if inst:IsA("ValueBase") then inst.Value = value return true end if inst:IsA("TextLabel") or inst:IsA("TextButton") or inst:IsA("TextBox") then inst.Text = tostring(value) return true end return false end function FC.getNumber(target) local v = FC.getValue(target) if type(v) == "number" then return v end if type(v) == "string" then return FC.parseNumber(v:match("[%d%.,]+[kKmMbBtT]?") or "") end return nil end -- ============================================ -- 5. PLAYER & KARAKTER -- ============================================ function FC.getCharacter(player) player = player or LP return player.Character end function FC.getRoot(player) local c = FC.getCharacter(player) return c and c:FindFirstChild("HumanoidRootPart") or nil end function FC.getHumanoid(player) local c = FC.getCharacter(player) return c and c:FindFirstChildOfClass("Humanoid") or nil end function FC.isAlive(player) local h = FC.getHumanoid(player) return h ~= nil and h.Health > 0 end function FC.getPlayer(name) if not name then return LP end name = lower(name) for _, p in ipairs(Players:GetPlayers()) do if p.Name:lower() == name or p.DisplayName:lower() == name then return p end end for _, p in ipairs(Players:GetPlayers()) do if p.Name:lower():find(name, 1, true) or p.DisplayName:lower():find(name, 1, true) then return p end end return nil end function FC.getPlayers(includeSelf) local out = {} for _, p in ipairs(Players:GetPlayers()) do if includeSelf or p ~= LP then table.insert(out, p) end end return out end function FC.getTool(name) local q = lower(name) local boxes = {LP.Character, LP:FindFirstChildOfClass("Backpack")} for _, box in ipairs(boxes) do if box then for _, t in ipairs(box:GetChildren()) do if t:IsA("Tool") and t.Name:lower() == q then return t end end end end return nil end function FC.equipTool(name) local tool = FC.getTool(name) local hum = FC.getHumanoid() if tool and hum then hum:EquipTool(tool) return true end return false end -- ============================================ -- 6. POSISI, KOORDINAT & GERAK -- ============================================ function FC.getPosition(x) if typeof(x) == "Vector3" then return x end if typeof(x) == "CFrame" then return x.Position end if type(x) == "string" then x = FC.findPath(x) end if not isInst(x) then return nil end if x:IsA("BasePart") then return x.Position end if x:IsA("Model") then return x:GetPivot().Position end if x:IsA("Attachment") then return x.WorldPosition end if x:IsA("Player") then local r = FC.getRoot(x) return r and r.Position end local p = x:FindFirstAncestorWhichIsA("BasePart") if p then return p.Position end local m = x:FindFirstAncestorWhichIsA("Model") if m then return m:GetPivot().Position end for _, d in ipairs(x:GetDescendants()) do if d:IsA("BasePart") then return d.Position end end return nil end function FC.distance(a, b) local pa = FC.getPosition(a) local pb = b and FC.getPosition(b) if not pb then local r = FC.getRoot() pb = r and r.Position end if not pa or not pb then return math.huge end return (pa - pb).Magnitude end function FC.nearest(list, from) local best, bestD = nil, math.huge for _, item in ipairs(list or {}) do local d = FC.distance(item, from) if d < bestD then best, bestD = item, d end end return best, bestD end function FC.sortByDistance(list, from) local copy = table.clone(list) table.sort(copy, function(a, b) return FC.distance(a, from) < FC.distance(b, from) end) return copy end -- Ubah apa pun jadi target local function resolveTarget(target) if typeof(target) == "Vector3" or typeof(target) == "CFrame" or isInst(target) then return target end if type(target) == "table" then local x = target.x or target.X or target[1] local y = target.y or target.Y or target[2] local z = target.z or target.Z or target[3] if x and y and z then return Vector3.new(x, y, z) end return nil end if type(target) == "string" then local inst = FC.findPath(target) if inst then return inst end local plr = FC.getPlayer(target) if plr and plr ~= LP then return plr end end return nil end function FC.getCordinate(target) local t = resolveTarget(target) if not t then return nil end return FC.getPosition(t) end function FC.getCordinateXYZ(target) local p = FC.getCordinate(target) if not p then return nil end local r = function(n) return math.floor(n * 100 + 0.5) / 100 end return r(p.X), r(p.Y), r(p.Z) end function FC.getCordinateText(target) local x, y, z = FC.getCordinateXYZ(target) if not x then return nil end return x .. ", " .. y .. ", " .. z end function FC.tweenTo(target, speed, offsetY, anchor) local hrp = FC.getRoot() local t = resolveTarget(target) local pos = FC.getPosition(t) if not hrp or not pos then return false end speed = math.max(speed or 60, 1) local dest = CFrame.new(pos + Vector3.new(0, offsetY or 3, 0)) if typeof(t) == "CFrame" then dest = dest * (t - t.Position) -- pertahankan rotasi end local wasAnchored = hrp.Anchored if anchor then hrp.Anchored = true end local dist = (hrp.Position - dest.Position).Magnitude local time = math.clamp(dist / speed, 0.05, 30) local tw = TweenService:Create(hrp, TweenInfo.new(time, Enum.EasingStyle.Linear), {CFrame = dest}) tw:Play() tw.Completed:Wait() if anchor then hrp.Anchored = wasAnchored end return true end function FC.walkTo(target, timeout) local hum = FC.getHumanoid() local pos = FC.getPosition(resolveTarget(target)) if not hum or not pos then return false end local done = false local conn = hum.MoveToFinished:Connect(function() done = true end) hum:MoveTo(pos) FC.waitFor(function() return done end, timeout or 10, 0.1) conn:Disconnect() return done end -- Teleport("world1.tower.pad", {mode = "Tween", speed = 80, offsetY = 5}) -- mode: "instant" (default) / "tween" / "walk" (huruf bebas) function FC.Teleport(target, opts) opts = opts or {} local hrp = FC.getRoot() if not hrp then return false, "no character" end local t = resolveTarget(target) if not t then return false, "target not found" end local pos = FC.getPosition(t) if not pos then return false, "no position" end local mode = lower(opts.mode or "instant") local offsetY = opts.offsetY or 3 if mode == "tween" then return FC.tweenTo(t, opts.speed or 60, offsetY, opts.anchor), "tween" elseif mode == "walk" then return FC.walkTo(t, opts.timeout or 10), "walk" end local dest = CFrame.new(pos + Vector3.new(0, offsetY, 0)) if typeof(t) == "CFrame" then dest = dest * (t - t.Position) end hrp.CFrame = dest return true, "instant" end local savedPos = {} function FC.savePosition(name) local hrp = FC.getRoot() if not hrp then return false end savedPos[lower(name or "default")] = hrp.CFrame return true end function FC.returnPosition(name) local hrp = FC.getRoot() local cf = savedPos[lower(name or "default")] if not hrp or not cf then return false end hrp.CFrame = cf return true end function FC.teleportNearest(list, opts) local nearest = FC.nearest(list) if not nearest then return false, "empty list" end return FC.Teleport(nearest, opts) end -- ============================================ -- 7. REMOTE & MODULE -- ============================================ function FC.findRemotes(root, nameFilter) root = (root and FC.findPath(root)) or game:GetService("ReplicatedStorage") local out = {} for _, d in ipairs(root:GetDescendants()) do if d:IsA("RemoteEvent") or d:IsA("RemoteFunction") then if not nameFilter or FC.contains(d.Name, nameFilter) then table.insert(out, d) end end end return out end function FC.fire(remote, ...) remote = FC.findPath(remote) if not remote or not remote:IsA("RemoteEvent") then return false end return (pcall(remote.FireServer, remote, ...)) end function FC.invoke(remote, ...) remote = FC.findPath(remote) if not remote or not remote:IsA("RemoteFunction") then return false, nil end return pcall(remote.InvokeServer, remote, ...) end function FC.require(module) module = FC.findPath(module) if not module or not module:IsA("ModuleScript") then return nil end local ok, res = pcall(require, module) if ok then return res end return nil end function FC.firePrompt(prompt) prompt = FC.findPath(prompt) if not prompt or not prompt:IsA("ProximityPrompt") then return false end if typeof(fireproximityprompt) == "function" then return (pcall(fireproximityprompt, prompt)) end return false end function FC.click(detector) detector = FC.findPath(detector) if not detector or not detector:IsA("ClickDetector") then return false end if typeof(fireclickdetector) == "function" then return (pcall(fireclickdetector, detector)) end return false end -- ============================================ -- 8. TABLE -- ============================================ function FC.count(t) local n = 0 for _ in pairs(t or {}) do n += 1 end return n end function FC.keys(t) local out = {} for k in pairs(t or {}) do table.insert(out, k) end return out end function FC.values(t) local out = {} for _, v in pairs(t or {}) do table.insert(out, v) end return out end function FC.deepCopy(t) if type(t) ~= "table" then return t end local out = {} for k, v in pairs(t) do out[k] = FC.deepCopy(v) end return out end function FC.filter(list, fn) local out = {} for i, v in ipairs(list or {}) do if fn(v, i) then table.insert(out, v) end end return out end function FC.map(list, fn) local out = {} for i, v in ipairs(list or {}) do table.insert(out, fn(v, i)) end return out end function FC.find(list, fn) for i, v in ipairs(list or {}) do if fn(v, i) then return v, i end end return nil end function FC.walk(t, fn, path, depth) path = path or "" depth = depth or 0 if type(t) ~= "table" or depth > 8 then return end for k, v in pairs(t) do local p = (path == "" and tostring(k)) or (path .. "." .. tostring(k)) fn(p, v, k) if type(v) == "table" then FC.walk(v, fn, p, depth + 1) end end end function FC.searchTable(t, query) local out = {} FC.walk(t, function(path, v) if FC.contains(path, query) or (type(v) ~= "table" and FC.contains(tostring(v), query)) then out[path] = v end end) return out end function FC.dump(t, indent) indent = indent or 0 if type(t) ~= "table" then return tostring(t) end local sp = string.rep(" ", indent) local s = "{\n" for k, v in pairs(t) do s = s .. sp .. " [" .. tostring(k) .. "] = " .. FC.dump(v, indent + 1) .. ",\n" end return s .. sp .. "}" end -- ============================================ -- 9. FILE (executor) -- ============================================ local hasFS = typeof(isfile) == "function" and typeof(readfile) == "function" and typeof(writefile) == "function" and typeof(isfolder) == "function" and typeof(makefolder) == "function" function FC.ensureFolder(path) if not hasFS then return false end if not isfolder(path) then makefolder(path) end return true end function FC.fileExists(path) return hasFS and isfile(path) or false end function FC.saveJson(path, data) if not hasFS then return false end local ok = pcall(function() writefile(path, HttpService:JSONEncode(data)) end) return ok end function FC.loadJson(path, default) if not hasFS or not isfile(path) then return default end local ok, res = pcall(function() return HttpService:JSONDecode(readfile(path)) end) if ok then return res end return default end function FC.copy(text) if typeof(setclipboard) == "function" then return (pcall(setclipboard, tostring(text))) end return false end -- ============================================ -- 10. CONNECTION MANAGER -- ============================================ local connections = {} function FC.connect(signal, fn, tag) local c = signal:Connect(fn) tag = lower(tag or "default") connections[tag] = connections[tag] or {} table.insert(connections[tag], c) return c end function FC.disconnect(tag) tag = lower(tag or "default") for _, c in ipairs(connections[tag] or {}) do pcall(function() c:Disconnect() end) end connections[tag] = nil end function FC.disconnectAll() local tags = {} for tag in pairs(connections) do table.insert(tags, tag) end for _, tag in ipairs(tags) do FC.disconnect(tag) end end -- ============================================ -- 11. GAME INFO -- ============================================ function FC.getGameName() local ok, info = pcall(function() return game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId) end) return (ok and info and info.Name) or "Unknown Game" end function FC.getCamera() return workspace.CurrentCamera end function FC.isMobile() local UIS = game:GetService("UserInputService") return UIS.TouchEnabled and not UIS.KeyboardEnabled end -- ============================================ -- 12. PROXIMITY -- ============================================ -- Ambil ProximityPrompt terdekat yang terjangkau -- range kosong = pakai MaxActivationDistance milik tiap prompt -- rootPath kosong = cari di seluruh workspace (isi untuk lebih cepat) function FC.getProximityNear(range, rootPath) local hrp = FC.getRoot() if not hrp then return nil end local root = (rootPath and FC.findPath(rootPath)) or workspace local best, bestD for _, d in ipairs(root:GetDescendants()) do if d:IsA("ProximityPrompt") and d.Enabled then local pos = FC.getPosition(d.Parent) if pos then local dist = (pos - hrp.Position).Magnitude local maxD = range or d.MaxActivationDistance if dist <= maxD and (not bestD or dist < bestD) then best, bestD = d, dist end end end end return best, bestD end -- proximityNear() -> tekan -- proximityNear(1) -> tahan 1 detik -- proximityNear(nil, 20) -> tekan, jangkauan 20 studs -- proximityNear(1, nil, "world1") -> tahan 1 detik, cari hanya di world1 function FC.proximityNear(hold, range, rootPath) local prompt, dist = FC.getProximityNear(range, rootPath) if not prompt then return false, "no prompt near" end if hold == nil then if typeof(fireproximityprompt) == "function" then pcall(fireproximityprompt, prompt) else pcall(function() prompt:InputHoldBegin() task.wait() prompt:InputHoldEnd() end) end else local seconds = tonumber(hold) or 1 local began = pcall(function() prompt:InputHoldBegin() end) task.wait(seconds) if began then pcall(function() prompt:InputHoldEnd() end) elseif typeof(fireproximityprompt) == "function" then pcall(fireproximityprompt, prompt) end end return true, prompt, dist end -- ============================================ -- ALIAS: nama fungsi tidak peka huruf besar/kecil -- ============================================ FC.getCoordinate = FC.getCordinate FC.getCoordinateXYZ = FC.getCordinateXYZ FC.getCoordinateText = FC.getCordinateText FC.teleport = FC.Teleport do local names = {} for k, v in pairs(FC) do if type(v) == "function" then table.insert(names, k) end end for _, k in ipairs(names) do local pascal = k:sub(1, 1):upper() .. k:sub(2) if FC[pascal] == nil then FC[pascal] = FC[k] end local low = k:lower() if FC[low] == nil then FC[low] = FC[k] end end end -- ===== USER ===== -- getUser() -> username kamu -- getUser("budi") -> username player lain (nama boleh sebagian) -- Mengembalikan: username, displayName, userId function FC.getUser(name) local plr = name and FC.getPlayer(name) or LP if not plr then return nil end return plr.Name, plr.DisplayName, plr.UserId end -- ===== SETUP BUY NEXT ITEMS ===== -- ============================================================ -- BUY NEXT ITEMS (lengkap + semua perbaikan) -- Tempel SELURUH isi file ini di FunctionFramework, SETELAH blok USER -- dan SEBELUM blok ALIAS (sebelum "FC.getCoordinate = FC.getCordinate"). -- Jika sebelumnya sudah menempel blok BUY NEXT ITEMS / SETUP BUY NEXT ITEMS -- versi lama, HAPUS keduanya dulu, lalu tempel file ini. -- ============================================================ -- ===== PERBAIKAN ANGKA (menimpa versi lama) ===== -- Mengenali singkatan: k, m, b, t, qa, qi, sx, sp, oc, no, dc function FC.parseNumber(str) if type(str) == "number" then return str end local s = tostring(str):lower():gsub(",", "") s = s:gsub("%s+", "") local direct = tonumber(s) if direct then return direct end local num, suffix = s:match("^%$?([%d%.]+)(%a*)$") num = tonumber(num) if not num then return nil end local mult = { k = 1e3, m = 1e6, b = 1e9, t = 1e12, qa = 1e15, qi = 1e18, sx = 1e21, sp = 1e24, oc = 1e27, no = 1e30, dc = 1e33, } return num * (mult[suffix] or 1) end function FC.getNumber(target) local v = FC.getValue(target) if type(v) == "number" then return v end if type(v) == "string" then return FC.parseNumber(v:match("%$?[%d,%.]+%s*%a*") or "") end return nil end -- ===== BUY NEXT ITEMS ===== local itemBlacklist = {} -- Baca uang (selalu nilai TERBARU): path teks / Instance / function. -- Angka tetap tidak diperbarui, hanya untuk uji coba. local function readCash(src) if type(src) == "number" then return src end if type(src) == "function" then local ok, v = pcall(src) return ok and tonumber(v) or 0 end if isInst(src) then return FC.getNumber(src) or 0 end if type(src) == "string" then local q = lower(src) local ls = LP:FindFirstChild("leaderstats") local c = ls and childLower(ls, q) if c then return FC.getNumber(c) or 0 end local real = realAttrName(LP, q) if real then return tonumber(LP:GetAttribute(real)) or 0 end -- path relatif ke pemain sendiri dulu, baru path global local mine = FC.findPath(src, {root = LP, strict = true}) if mine then return FC.getNumber(mine) or 0 end return FC.getNumber(src) or 0 end return 0 end -- Dukung {Item1 = 1900, Item2 = 2500} atau {{"Item1", 1900}, {"Item2", 2500}} local function normalizeItems(items) local list = {} if type(items) ~= "table" then return list end if type(items[1]) == "table" then for i, it in ipairs(items) do local n = it.name or it.Name or it[1] local p = tonumber(it.price or it.Price or it.cost or it.Cost or it[2]) if n and p then table.insert(list, {name = tostring(n), price = p, order = i}) end end else for n, p in pairs(items) do p = tonumber(p) if p then table.insert(list, {name = tostring(n), price = p, order = 0}) end end end return list end local function normMode(mode) local m = lower(mode or "frombottom"):gsub("[%s_%-]", "") if m:find("near") or m:find("top") then return "nearest" end if m:find("list") then return "list" end return "bottom" end local function pickItem(pool, mode) if #pool == 0 then return nil end if mode == "nearest" then table.sort(pool, function(a, b) return a.price > b.price end) elseif mode == "list" then table.sort(pool, function(a, b) if a.order ~= b.order then return a.order < b.order end return a.name < b.name end) else table.sort(pool, function(a, b) return a.price < b.price end) end return pool[1] end local function doBuy(buy, name, price) if type(buy) == "function" then return pcall(buy, name, price) elseif type(buy) == "string" then local r = FC.findPath(buy) if not r then return false end if r:IsA("RemoteFunction") then return FC.invoke(r, name) end return FC.fire(r, name) end return false end -- buyNextItems(cash, items, mode, buy, opts) -- cash : "leaderstats.Wins" / Instance / function / angka (tes) -- items : {Item1 = 1900, Item2 = 2500} -- mode : "fromBottom" (termurah) / "nearestLowCash" (termahal yang mampu) / "list" -- buy : function(name, price) / path remote -- opts : all, max, repeatable, wait, retryAfter, continueOnFail, -- owned (table / function), verify, onBought, -- bought (table ingatan), blacklist (table per grup) -- Hasil: ok, daftarNamaYangDibeli, uangSekarang, alasan function FC.buyNextItems(cashSrc, items, mode, buy, opts) opts = opts or {} local list = normalizeItems(items) if #list == 0 then return false, {}, readCash(cashSrc), "no items" end mode = normMode(mode) local bl = opts.blacklist or itemBlacklist local mem = opts.bought local skip = {} if type(opts.owned) == "table" then for k, v in pairs(opts.owned) do if v then skip[lower(k)] = true end end end local function isSkipped(name) local key = lower(name) if skip[key] then return true end if mem and mem[key] then return true end if (bl[key] or 0) > os.clock() then return true end if type(opts.owned) == "function" then local ok, res = pcall(opts.owned, name) if ok and res then return true end end return false end local maxBuys = 1 if opts.all then maxBuys = opts.max or (opts.repeatable and 50 or #list) end local bought, buys = {}, 0 local reason = "nothing affordable" for _ = 1, maxBuys + #list do if buys >= maxBuys then break end local cash = readCash(cashSrc) local pool = {} for _, it in ipairs(list) do if it.price <= cash and not isSkipped(it.name) then table.insert(pool, it) end end local it = pickItem(pool, mode) if not it then break end doBuy(buy, it.name, it.price) task.wait(opts.wait or 0.4) local newCash = readCash(cashSrc) local success if opts.verify then local s, r = pcall(opts.verify, it.name, it.price, cash, newCash) success = s and r and true or false else success = newCash < cash end if success then buys += 1 table.insert(bought, it.name) if not opts.repeatable then skip[lower(it.name)] = true if mem then mem[lower(it.name)] = true end end if opts.onBought then pcall(opts.onBought, it.name, it.price) end else bl[lower(it.name)] = os.clock() + (opts.retryAfter or 10) reason = "buy failed: " .. it.name if not opts.continueOnFail then break end end end local finalCash = readCash(cashSrc) if #bought == 0 then return false, bought, finalCash, reason end return true, bought, finalCash end function FC.clearItemBlacklist() itemBlacklist = {} end -- ===== SETUP BUY NEXT ITEMS ===== local buyGroups = {} -- Ganti @item / {item} dan @price / {price} (huruf bebas), juga di dalam teks local function fillArg(v, name, price) if type(v) ~= "string" then return v, false end local found = false local low = v:lower() if low == "@item" or low == "{item}" then return name, true end if low == "@price" or low == "{price}" then return price, true end local out = v:gsub("@[Ii][Tt][Ee][Mm]", function() found = true return name end) out = out:gsub("{[Ii][Tt][Ee][Mm]}", function() found = true return name end) out = out:gsub("@[Pp][Rr][Ii][Cc][Ee]", function() found = true return tostring(price) end) out = out:gsub("{[Pp][Rr][Ii][Cc][Ee]}", function() found = true return tostring(price) end) return out, found end local function buildArgs(spec, name, price, appendItem) if type(spec) == "function" then local ok, res = pcall(spec, name, price) if ok and type(res) == "table" then return res end return {name} end if spec == nil then return {name} end if type(spec) ~= "table" then spec = {spec} end local args, hasItem = {}, false for i = 1, #spec do local v, used = fillArg(spec[i], name, price) args[i] = v if used then hasItem = true end end if not hasItem and appendItem then table.insert(args, name) end return args end local function makeBuyFn(g) return function(name, price) local args = buildArgs(g.args, name, price, g.appendItem) local r = g.remote if type(r) == "function" then return r(name, price, args) end if type(r) == "string" or isInst(r) then r = FC.findPath(r) end if not r then return false end if r:IsA("RemoteFunction") then return pcall(r.InvokeServer, r, table.unpack(args)) elseif r:IsA("RemoteEvent") then return pcall(r.FireServer, r, table.unpack(args)) end return false end end local function runGroup(g) local items = g.items if type(items) == "function" then local ok, res = pcall(items) items = ok and res or {} end if g.condition then local ok, res = pcall(g.condition) if ok and res == false then return false, {}, nil, "paused" end end return FC.buyNextItems(g.cash, items, g.mode, makeBuyFn(g), g.opts) end -- setupBuyNextItems{id=, cash=, items=, mode=, remote=, args=, ...} -- atau setupBuyNextItems(id, cash, items, mode, remote, args, opts) -- id : nama unik, contoh "trail" -- cash : "leaderstats.Wins" / Instance / function (selalu dibaca ulang) -- items : {Item1 = 1900, ...} atau function yang mengembalikan table itu -- mode : "fromBottom" / "nearestLowCash" / "list" -- remote : path remote / instance remote / function(name, price, args) -- args : "@item" = nama item, "@price" = harga -- {"Unlock", "@item"} / {"@item", "Unlock", 1} / {"Unlock", 1} -- function(name, price) return {{Action = "Buy", TrailName = name}} end -- opts : interval (default 1.5), condition (fn, false = jeda), -- all, max, repeatable, owned, verify, onBought, wait, retryAfter, -- continueOnFail (lanjut ke item lain jika gagal), appendItem=false function FC.setupBuyNextItems(id, cash, items, mode, remote, args, opts) local raw if type(id) == "table" then raw = id else raw = {id = id, cash = cash, items = items, mode = mode, remote = remote, args = args} for k, v in pairs(opts or {}) do raw[k] = v end end local c = {} for k, v in pairs(raw) do c[lower(k)] = v end if not c.id then return false, "id required" end local key = lower(c.id) local old = buyGroups[key] local wasEnabled = old and old.enabled or false if old then FC.setBuyNextItem(key, false) end local g = { id = key, cash = c.cash, items = c.items, mode = c.mode, remote = c.remote, args = c.args or c.argument or c.arguments, interval = tonumber(c.interval) or 1.5, condition = c.condition, appendItem = c.appenditem ~= false, enabled = false, opts = { all = c.all, max = c.max, repeatable = c.repeatable, owned = c.owned, verify = c.verify, onBought = c.onbought, wait = c.wait, retryAfter = c.retryafter, continueOnFail = c.continueonfail, }, } -- ingatan & blacklist terpisah per grup (nama sama di grup lain tidak bentrok) g.bought = old and old.bought or {} g.blacklist = old and old.blacklist or {} g.opts.bought = g.bought g.opts.blacklist = g.blacklist buyGroups[key] = g if wasEnabled then FC.setBuyNextItem(key, true) end return true, key end -- setBuyNextItem("trail", true) -> nyalakan -- setBuyNextItem("trail", false) -> matikan -- setBuyNextItem("trail") -> balik status function FC.setBuyNextItem(id, state) local g = buyGroups[lower(id)] if not g then return false, "id not found" end if state == nil then state = not g.enabled end state = state and true or false if state == g.enabled then return state end g.enabled = state if state then local token = {} g.token = token task.spawn(function() while g.enabled and g.token == token do pcall(runGroup, g) task.wait(g.interval) end end) else g.token = nil end return state end function FC.getBuyNextItem(id) local g = buyGroups[lower(id)] return g and g.enabled or false end -- Jalankan sekali manual (tanpa menyalakan loop) function FC.runBuyNextItem(id) local g = buyGroups[lower(id)] if not g then return false, {}, nil, "id not found" end return runGroup(g) end function FC.updateBuyNextItems(id, items) local g = buyGroups[lower(id)] if not g then return false end g.items = items return true end -- Kosongkan ingatan item yang sudah dibeli (pakai setelah rebirth jika item di-reset) function FC.resetBuyNextItem(id) local g = buyGroups[lower(id)] if not g then return false end g.bought = {} g.blacklist = {} g.opts.bought = g.bought g.opts.blacklist = g.blacklist return true end function FC.removeBuyNextItem(id) local key = lower(id) if buyGroups[key] then FC.setBuyNextItem(key, false) buyGroups[key] = nil return true end return false end function FC.listBuyNextItems() local out = {} for k, g in pairs(buyGroups) do out[k] = g.enabled end return out end return FC