JQuery for Roblox, kind of. Easy to use "library" for Roblox games

Introducing jQuery for Roblox

Before I explain what this model is, do note that it is only very similar to jQuery and not a full-on port. Also you'll more than likely encounter issues with ScreenGuis as this is mainly for other UI objects.

Think of jQuery for Roblox as a tool that makes scripting your UI a lot more fun and straightforward. It’s all about making it easier to create and manage your UI elements through scripting.

With this model, you'll get some features that make UI scripting simple. Here’s what you can look forward to:

  • Simplified UI Creation (via script): You can make new UI elements quickly with a few lines of code. No more setting properties one by one, just use a singular table to create and customize your frames, buttons, and more.
  • Styling made easy: Add cool things like rounded corners and borders to your UI elements without any hassle. The model takes care of the styling, so you can focus on what your UI should do.
  • Event Handling Made Easy:Attach event listeners to your UI elements (any) and handle user actions like you usually do.
  • Feature rich I'd say: There's more to it than shown here. jQuery for Roblox has things like a find feature for UI, animate, empty, eq and more.

Overall, this model is all about making your life easier when it comes to creating and managing user interfaces in Roblox. I will definitely be using this myself as I created it for enhancing my development experience. I'm not sure if I'll be using this in any community resource projects though, not sure if people would like that.

There are two ways to add the model, from which the former(1) will keep the model up to date at all times:

Way1

Add the following code to a Script in ServerScriptService:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InsertService = game:GetService("InsertService")

local GetModuleSource = Instance.new("RemoteFunction")
GetModuleSource.Name = "GetModuleSource"
GetModuleSource.Parent = ReplicatedStorage

local moduleId = 18647936998

local function createModuleForPlayer(player)
    local module = InsertService:LoadAsset(moduleId)
    local moduleScript = module:FindFirstChildOfClass("ModuleScript")

    if moduleScript then
        local playerGui = player:WaitForChild("PlayerGui")
        local newModuleScript = moduleScript:Clone()
        newModuleScript.Name = "LoadedjQuery"
        newModuleScript.Parent = playerGui
        moduleScript:Destroy()
        module:Destroy()

        return newModuleScript:GetFullName()
    else
        return nil
    end
end

GetModuleSource.OnServerInvoke = createModuleForPlayer

Add the following code to a LocalScript in your desired location:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local GetModuleSource = ReplicatedStorage:WaitForChild("GetModuleSource")
local player = Players.LocalPlayer

local function requireModuleFromServer()
    local success, moduleLocation = pcall(function()
        return GetModuleSource:InvokeServer()
    end)

    if success and moduleLocation then
        local playerGui = player:WaitForChild("PlayerGui")
        local loadedModuleScript = playerGui:WaitForChild("LoadedjQuery")
        return require(loadedModuleScript)
    else
        warn("Failed to load jQuery from server.", moduleLocation)
        return nil
    end
end

local Document = requireModuleFromServer()

if Document then
end
Way2

Follow these steps to add the model directly:

  1. Go to the asset page: jQuery for Roblox.
  2. Add the model to ReplicatedStorage.
  3. Rename the model to jQuery to avoid conflicts with other modules.
  4. Add the following line to a LocalScript:
local Document = require(game.ReplicatedStorage.jQuery)
  
Example Tutorial

Here's a brief tutorial on how to use the model to create a simple UI and add functionality to buttons:

Creation of UI:

-- Define the window (Which is a full screen frame inside a ScreenGui called Window at the moment
local Window = Document.new(game.Players.LocalPlayer.PlayerGui.ScreenGui.Window)

-- Create the menu Frame like so and define the properties of it inside a table as a secondary value:
local MenuFrame = Document:create("Frame", {
    Name = "ExampleFrame",
    Size = UDim2.new(0, 300, 0, 300),
    Position = UDim2.new(0.5, -150, 0.5, -150),
    BackgroundColor3 = Color3.fromRGB(53, 53, 53),
    Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui.Window
}):rounded(20):border(2, Color3.new(0.529412, 0.960784, 1))

-- Do the same as above but this time as a TextLabel or a TextButton, do note I used MenuFrame:width() and MenuFrame:height() to get the x,y offset of the MenuFrame, you can use those to set the offset by adding a number value to them.
local Play = MenuFrame:create("TextLabel", {
    Name = "Button",
    Size = UDim2.new(0, MenuFrame:width()[1]-5, 0, MenuFrame:height()[1]/4-5),
    Position = UDim2.new(0, 2.5, 0, 2.5),
    BackgroundColor3 = Color3.fromRGB(63, 63, 63),
    Parent = MenuFrame.objects[1],
    Text = "PLAY",
    TextScaled = true,
    TextColor3 = Color3.fromRGB(255, 255, 255)
}):rounded(20):border(1, Color3.new(0.666667, 0.666667, 1))

--Again
local Store = MenuFrame:create("TextLabel", {
    Name = "Button",
    Size = UDim2.new(0, MenuFrame:width()[1]-5, 0, MenuFrame:height()[1]/4-5),
    Position = UDim2.new(0, 2.5, 0, MenuFrame:height()[1]/4+2.5),
    BackgroundColor3 = Color3.fromRGB(63, 63, 63),
    Parent = MenuFrame.objects[1],
    Text = "STORE",
    TextScaled = true,
    TextColor3 = Color3.fromRGB(255, 255, 255)
}):rounded(20):border(1, Color3.new(0.666667, 0.666667, 1))

-- and again
local Settings = MenuFrame:create("TextLabel", {
    Name = "Button",
    Size = UDim2.new(0, MenuFrame:width()[1]-5, 0, MenuFrame:height()[1]/4-5),
    Position = UDim2.new(0, 2.5, 0, MenuFrame:height()[1]/4*2+2.5),
    BackgroundColor3 = Color3.fromRGB(63, 63, 63),
    Parent = MenuFrame.objects[1],
    Text = "SETTINGS",
    TextScaled = true,
    TextColor3 = Color3.fromRGB(255, 255, 255)
}):rounded(20):border(1, Color3.new(0.666667, 0.666667, 1))

-- And once more
local Quit = MenuFrame:create("TextLabel", {
    Name = "Button",
    Size = UDim2.new(0, MenuFrame:width()[1]-5, 0, MenuFrame:height()[1]/4-5),
    Position = UDim2.new(0, 2.5, 0, MenuFrame:height()[1]/4*3+2.5),
    BackgroundColor3 = Color3.fromRGB(63, 63, 63),
    Parent = MenuFrame.objects[1],
    Text = "QUIT",
    TextScaled = true,
    TextColor3 = Color3.fromRGB(255, 255, 255)
}):rounded(20):border(1, Color3.new(0.666667, 0.666667, 1))

Button Functionality:

-- Add a click event listener to Play like so and set the click action to hide the MenuFrame. You can add more to it if you so wish.
Play:on('click', function()
    MenuFrame:hide()
end)

-- Same here but instead make the action be a kick due to the button being a Quit button.
Quit:on('click', function()
    game.Players.LocalPlayer:Kick("Exit")
end)

Note: The examples above are just a small portion of what you can achieve with this model. You can manually create and customize your UI elements with Document:new(object) as needed. For further details, refer to the documentation linked below.

Here's an image of the UI created in the tutorial:

image

Some questions that some might ask

  • Why should I use jQuery for Roblox?
    In most cases, using jQuery for Roblox is a lot more efficient than doing it normally. A great example would be click events and setting properties, as jQuery for roblox allows click events on frames and textlabels like shown above and setting properties is extremely simple and performed in a table.

  • How do I use manually created UI with jQuery for Roblox?
    As shown in the tutorial, you create a variable and make it the following:

local name = Document.new(path to object)

Additional Resources:

For more information, visit the official jQuery for Roblox Documentation.

For good practices, when using each, always use :clean() on the object to free it from memory.

Links:

8 Likes

Note

What More
Changelogs I will add changelogs to the Documentation page within 04/08/2024 (Added 02/08/2024)
Usage I will continue to work on it to make it nicer to use, right now make sure to read Documentation to fully understand it
Updates? I will maintain jQuery for Roblox and keep it up to date. I personally use it, which is why I must maintain it. I do recommend using the script way to insert it due to the future fixes and cool additions!

…why?

this is cool and all but jquery isn’t even popular on the web anymore :sob:

I haven’t looked too deeply into your library. But if it’s practically a replica of jQuery on the web for Roblox - please be informed that jQuery is generally looked down upon as poorly designed and not great to use.

Many of the issues that jQuery tries to “fix” don’t even exist on the modern web anymore. Perhaps it is a nice to have utility, but most of what it does can either be achieved in pure JS or using modern frameworks.

Not a complete replica due to Roblox limitations, it’s a nice to have and has features that people would want but preferably not make themselves.

Solves issues like custom mouse icons turning into the default Roblox mouse icon by allowing click detection anywhere and also fixes most issues I’ve come across during the time I’ve spent making projects on Roblox.
I’d say it should be used only if actually needed or if a script’s getting too large.