roblox-ts

R

roblox-ts

Join the community to ask questions about roblox-ts and get answers from other members.

Join

Flamework Tips

Hello all, First with some context: I've been in the process of porting some games run by a group to use Rojo and even more recently I've been porting some code to use Typescript. I have familiarity with Typescript and React already. What I'm not familiar is Flamework and frameworks similar to it. ...

flamework not identifying service constructor

tl;dr services cannot be in shared I am using flamework for the first time and I'm not sure whether this is a conceptual misunderstanding or there is something I'm not seeing I have the following service (shared):...
Solution:
iirc services cant be made in shared, services is for server only, controllers is for client only, and components are for all three (client, shared, server). You'd have to make the SessionProvider service be serversided. Also for the SessionProvider you have to use the existing life-cycle events that flamework provides you with (onStart, onTick, etc...) to add logic to the listeners
Message Not Public
Sign In & Join Server To View

how to use rbxts-build in a multi-placed project

https://github.com/osyrisrblx/rbxts-build I want to use rbxts-build in a multi-place project. What settings should I write in project.json? Or is it not possible? Currently, there are main and lobby places like this. ```...
Solution:
"watch:lobby": "cd places/lobby && rbxts-build watch",
"watch:main": "cd places/main && rbxts-build watch"
"watch:lobby": "cd places/lobby && rbxts-build watch",
"watch:main": "cd places/main && rbxts-build watch"
...

How do you deal with multiple calls of FindFirstChild(), WaitForChild(), etc?

I'm new to both Rojo and Roblox-ts. One thing I noticed is that when I'm trying to access children of Instances is I'm having to repeatedly use FindFirstChild or WaitForChild or other methods and then having to use type casting or checking if the instance exists before finding the next child and so on and so forth Original luau code that looked like this: ```lua local track = self.Humanoid.Animator:LoadAnimation(ReplicatedStorage.Animations.Animation)...

Character and Skin Data Structure

I'm currently implementing a character selection system in a Roblox game and would like to hear everyone's opinions on how to structure the data. ``` // Character types (5 types) enum CharacterType { Warrior = "Warrior",...
Solution:
I would make a CharacterData const object with both the name and skins for each character
Message Not Public
Sign In & Join Server To View

Help with charm and lyra

Lyra is supposed to be the source of truth so how would I go about using charm-sync with lyra since atoms can be modified from anywhere and wont that make lyra not the source of truth

why it happens??

im not sure what is it and why it happens, anyone had this? This thing yields flamework entirely...
Solution:
it's waiting on the client cause they havent been created from the server yet
No description

Incorret t compilation with flamework

const test_guard = Flamework.createGuard<[string, ...unknown[]]>();
warn("[RESULT]", test_guard(["test", 123, "hi"])); //fails
const test_guard = Flamework.createGuard<[string, ...unknown[]]>();
warn("[RESULT]", test_guard(["test", 123, "hi"])); //fails
...

How to observe client-side data changes in Charm without React?

I'm using Charm for state management in my Roblox game and have successfully set up server-client synchronization using the official example from the charm-example repository. The server-side implementation works perfectly with the provided example. However, I'm not using React on the client side and need guidance on the best practices for observing atom changes and updating the UI accordingly. Here's my current client-side code: ```...
Solution:
you can create a custom useAtom hook
Message Not Public
Sign In & Join Server To View

UI elements are not compiling into lua

hey, it's possible that i am just wrong because I haven't really worked with anything for a while but for some reason UI elements are not compiling into lua. I am not sure if it should be like that but i suppose no because i get errors
No description

"tables cannot be cyclic"

log (from the compiled version):
error: tables cannot be cyclic - Client - ui_debug:11
error: tables cannot be cyclic - Client - ui_debug:11
codebase: https://github.com/msfyre/rpg_game/tree/battle-manager...
Solution:
stupid fix (it worked somehow): ```typescript export class BattleData // prev code here...

How do i properly write typings for generic

I have array which contains connected property class or separated property class. SeparetedProperty class needs generic of what type this property contains. But when i try to type it as unkown, because it can contain any type it throws error when i try to add property i cant really provide playground cuz it have lot of dependincies...
No description

Charm + ReadonlyMap Issue: forEach shows data but get() returns nil for same userId in atom sub

I'm having a weird issue with Charm in my RBXTS project on Roblox. I'm using an atom that holds a ReadonlyMap<number, PlayerData> for player states (where keys are UserIds as numbers). When a player joins, they're added to the map during hydration (I'm using charm-sync + tether), and I can see their initial state on the client-side (e.g., afk: false). After about 2 seconds, I update the local player's afk to true by creating a new map immutably and setting the atom. In my subscribe callback, I iterate over the state with forEach, and it correctly prints all entries, including my local UserId with the updated afk: true. However, in the same callback, when I manually do state.get(localPlayer.UserId), it returns nil every time; even though the UserId matches exactly what's shown in the iteration. ...

How do i specify keyof

How do i specify Name type so it contains only properties of type number?
No description

Can someone roast me hard

I made my very first usable class on ts and i want someone to roast it. Like point to any bad practises and other things Heres playground with this class: https://roblox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8vSCAWSgQItBSFE0RyLpRsawVhSgOYxjalJJRCHybAANRNfqxoa3rsFanV2oetazAgDbXuM+qcoWvKHo2jhkpqm7fBuh7xh2vaDtRBkch8rCOFQCy5nhuBno+Ncxn1HqmqcrU-oBsHhuJi1Sa85rIehyybvaqMWL45jwzev5fyjJmluMG6w3TbbcGRqNEfF9ZTVp9MSMTNa5lFZ5-kJpERK59N6ZagXzJh76oydV51P4piSepndFJgZnjBXG0qhqRJMuBwbLYsOY9ZSowbo2U9XebWtQVbBC5gAQn1MXdplrCtbVGCLY+xnLahwWfe+pj+2coSSFbNM1R14hk4+1P9ZZw2tQ5yTCP7B9pNIIA wth is this link bruh also i gave screen how it can be used i also used flamework component thingy for it...
No description

Tether and Charm examples

I'm working on a Roblox-ts project and want to integrate Tether for networking (message-based with type validation) and Charm for state management (atomic/immutable atoms). My goal is to handle client-server interactions like: Broadcasting updates to all clients (e.g., a player sends an AFK request to the server, which updates a shared atom for everyone to see the status), ..or sending targeted updates to individual clients (e.g., a player clicks a UI button, sends a request to the server to increment a counter, and the server responds only to that client with the updated value in their private atom). ...

How do i type property as provided type

I'm making my property implementation and i need to get access to instance's property using just name of it. in roblox studio you can just do Instance[property_name] and it will return property, but how i can do it in ts?
No description