Useful Packages

Eryn Lynn edited this page Dec 1, 2018 · 4 revisions

Here's a list of useful npm packages that are compatible with roblox-ts.

rbx-services

Exports most commonly used Roblox services. This makes them really easy to use.

import { Players } from "rbx-services";
Players.PlayerAdded.Connect(player => print("Player was added!", player.Name));

rbx-event

A type safe implementation of BindableEvents written in TypeScript

import { Event } from "rbx-event";
const e = new Event<[number, string]>();
e.connect((a, b) => print(a, b));
let n = 0;
while (true) {
    wait(1);
    e.fire(++n, "test");
}

rbx-inspect

A copy of kikito's inspect.lua library with type definitions.

import inspect = require("rbx-inspect");
print(inspect([1, 2, 3]));

rbx-datastore2

A copy of Kampfkarren's DataStore2 library with type definitions.

import { ReplicatedStorage, Players } from "rbx-services";
import DataStore2 = require("rbx-datastore2");

Players.PlayerAdded.Connect(player => {
    const coinsStore = DataStore2<number>("coins", player);

    const cointAmountRemote = ReplicatedStorage.CoinAmount as RemoteEvent;
    function callRemote(value: number) {
        cointAmountRemote.FireClient(player, value);
    }

    // Fire a remote event to the player telling them how many coins they have.
    // If this is their first time playing the game, they'll start out with 100.
    callRemote(coinsStore.Get(100));

    // Everytime the coin store updates, we'll send the RemoteEvent again.
    coinsStore.OnUpdate(callRemote);
});

rbx-resources

rbx-resources lets you easily access game assets and create named instances in your game.

const event = getResource(RemoteEvent, "SomeRemoteEvent");
const sword = getResource<Model>("Weapon", "Darkheart");
const bindable = getLocalResource(BindableEvent, "FooBarBaz");

rbx-roact

TypeScript and JSX support for Roact.

import * as Roact from 'rbx-roact';

const LocalPlayer = game.GetService("Players").LocalPlayer as Player;
const PlayerGui = LocalPlayer.FindFirstChildOfClass("PlayerGui");

const tree = <screengui>
  <textlabel Key="Label" Text="Hello, World!" Size={new UDim2(1, 0, 1, 0)}/>
</screengui>;

Roact.mount(tree, PlayerGui, "HelloWorld");

rbx-cmdr

Cmdr is a fully extensible and type safe command console for Roblox developers.

Great for admin commands, but does much more.

  • Make commands that tie in specifically with your game systems.
  • Intelligent autocompletion and instant validation.
  • Run commands programmatically on behalf of the local user.
  • Bind commands to user input.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.