KronHub Community Scripts

KronHub v3 · Community tab

Community Scripts

Write a single .lua file and it gets its own mini tab inside KronHub, with the same buttons, toggles, sliders, dropdowns, keybinds and text boxes the hub uses.

  • One file per script
  • Loads from workspace or a raw URL
  • Auto-updates from --@url
  • Errors can't break the hub

For players

  1. Put .lua files in your executor's workspace/KronHub/Community folder, or paste a raw link into Raw URL and press Import from URL.

  2. Open the Community tab and press Load next to the script under Installed.

  3. Its controls appear under Running. Click a card's header to collapse it. Press Unload to stop the script and remove its controls.

Scripts stay in the folder, so they're still listed the next time you open KronHub. Press Load to start one again.

Only load scripts from people you trust

Community scripts run with the same access as KronHub: files, HTTP and your account. Imported scripts update themselves from their URL every time you load them, so the author can change the code later.

Writing a script

Press Create Template in the Community tab. It writes workspace/KronHub/Community/Template.lua, which you can edit in any text editor. To reload after editing, press Unload and then Load.

--@name My Script
--@author YourName
--@version 1.0
--@description What your script does

local Tab, Hub = ...

Tab:NewSection("Main")

Tab:NewButton("Say hi", function()
    Hub:Notify("My Script", "Hello!", 3)
end)

Tab:NewToggle("Example toggle", false, function(state)
    print("Example toggle:", state)
end)

Tab is your card: everything you add shows up inside it, in the order you add it. Hub holds helpers like notifications. The method names and arguments are the same as KronHub's own tabs.

Elements

MethodCallback receivesReturns
NewSection––
NewLabel––
NewButtonnothingtext label (set .Text)
NewToggletrue / falseobject with :Set()
NewSlidernumbervalue box
NewDropDownpicked optionobject with list methods
NewKeyBindkey name, e.g. "F"–
NewBoxcurrent text–

Section

Tab:NewSection(text)

Tab:NewSection("Main")

A bold heading that groups the elements below it.

Label

Tab:NewLabel(text)

Tab:NewLabel("Some text")

A row of plain text.

Button

Tab:NewButton(text, callback)

local button = Tab:NewButton("Start", function()
    print("clicked")
end)

button.Text = "Stop"

Returnsthe button's text label. Change .Text to relabel it, for example for Start/Stop buttons.

Toggle

Tab:NewToggle(text, default, callback)

local toggle = Tab:NewToggle("Auto chop", false, function(state)
    print("on?", state)
end)

toggle:Set(true)

default = true starts it on and fires the callback once.

Returnsan object with :Set(state). Call :Set() with no argument to flip it.

Slider

Tab:NewSlider(text, default, min, max, precise, callback)

Tab:NewSlider("Speed", 16, 16, 100, false, function(value)
    print(value)
end)

The callback fires once with default when the slider is created. precise = true allows one decimal place (12.5); false gives whole numbers. Players can also type a number into the box on the right.

Dropdown

Tab:NewDropDown(text, options, callback)

local trees = Tab:NewDropDown("Tree:", {"Oak", "Birch"}, function(choice)
    print(choice)
end)

trees:Update("Walnut")        -- add an option
trees:UpdateRemove("Birch")   -- remove an option
trees:SetList({"Oak", "Koa"}) -- replace every option
trees:SetName("Tree: Oak")    -- change the text on the box

Players can type into the box to search and press Enter to pick the top match. End the label with : because the box shows label choice after a pick, e.g. Tree: Oak.

The four-argument form NewDropDown(text, options, reset, callback) also works. Pass reset = false to show Selected: choice and highlight the picked option instead.

Keybind

Tab:NewKeyBind(text, defaultKey, callback)

Tab:NewKeyBind("Toggle fly", Enum.KeyCode.F, function(key)
    print(key, "pressed") -- "F"
end)

The default can be an Enum.KeyCode or a string like "F". Players click the box and press a key to rebind it.

Text box

Tab:NewBox(text, default, callback)

Tab:NewBox("Webhook", "", function(text)
    print(text)
end)

The callback runs on every keystroke with the full current text.

Cleaning up

When a player presses Unload, KronHub automatically:

  • removes your card and all its elements
  • stops every element callback, so buttons, toggles and keybinds do nothing after unload
  • disconnects everything you connected with Tab:Connect
  • runs your Tab:OnUnload functions

Anything else you start has to stop itself:

Tab:Connect(game:GetService("RunService").Heartbeat, function(dt)
    -- disconnected automatically on unload
end)

Tab:OnUnload(function()
    workspace.CurrentCamera.FieldOfView = 70 -- undo your changes here
end)

task.spawn(function()
    while Tab:IsAlive() do -- stops when unloaded
        task.wait(1)
    end
end)
MethodUse it for
Tab:Connect(signal, fn)Any event connection. Returns the connection.
Tab:OnUnload(fn)Undoing changes: restore settings, destroy parts you made.
Tab:IsAlive()Loop condition. false once the script is unloaded.

Don't use while true do loops or plain :Connect calls. They keep running after unload, and run twice if the script is loaded again.

Hub helpers

Hub:Notify("My Script", "Done!", 3)

local progress = Hub:Progress("Moving:", 25) -- shows "Moving: 0/25"
for i = 1, 25 do
    progress:Update()                        -- 1/25, 2/25 … closes itself at 25/25
end
progress:Del()                               -- close it early
MemberWhat it is
Hub:Notify(title, text, seconds)KronHub toast notification.
Hub:Progress(title, total)Progress toast. :Update() adds one, :Del() closes it.
Hub.KronKronHub's internal helpers, e.g. Hub.Kron:callServer(name, ...), Hub.Kron:ForceNetworkOwnership(part), Hub.Kron:IsNetworkOwner(part), Hub.Kron:buyItem(name, amount). These can change between KronHub versions.
Hub.FlagsCurrent values of KronHub's toggles, sliders and dropdowns, keyed by their label. Read only.

Errors

Your script and every callback run in protected mode, so an error doesn't break KronHub. It's printed in the F9 console as:

[KronHub Community] <script name>: <error>

If the script errors while loading, its card is removed and a notification says it crashed. Syntax errors are reported the same way.

Publishing

  1. Upload the file somewhere with a raw link, such as GitHub raw or Pastebin raw.

  2. Add --@url <that link> to the header. KronHub also adds it automatically on import.

  3. Share the link. Players paste it into Raw URL and press Import from URL.

  4. To ship an update, change the file at the same link. Players get it the next time they press Load.