roblox-ts

R

roblox-ts

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

Join

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-ts.com/playground/#code/JYWwDg9gTgLgBAbzgJQK4DsDKBTKA3YAY2zgF84AzKCEOAIgAEoAjADxgGcB6D3A4jnQDcAKBHZWkWHEIAbAIYcOcHGHmx12ACYAFamFwwAngB4AKgD5EIgJBRs8rRHSyjcdPJDYAXHA4woYHQAc1FbMGoYbEIorTg8eVlUHzgzURtCAAt5EO1fZAAhAA1MQkCwGExgYI9ZEwBhRNlmeUIAawswmwLsbIIIVCgOXwRbGwB5dDMiNt8AChhM4GH4iGAtAEo4AF4rPDWtdIn0euzcrXnF5d999YAad2wAdwB9BKSUsweIWS03xOSvjMW12q3WR0aWGwMEuSxWt02OyszAgPwc6HSpC6EQgURi2jgLyyOWC2hezCCFzgBUp8mYsmwAFE8Nh0DAGk0Wu1OmIMs5-FBUDFoHMPF5fAKgsEHu9AaktqMbDYrhwAHRikjbdyebBHFWq2Wa+IA3W85Vw1VEs6kv4U9BxLXoZ5wACS6H8OWIczoNPtdIZzNZMDoGz1FuJ5x2cH1VpJZLtWlVgbZXXNy1VPT6wAGQyjiqVk2m7TmCtIdzGx1Oca0JcQZYrkJwMFr+aV9hgg3Q0cFpqVNnrSqxZv1EZtqvqzidMQWFsz8n6gzVkyr51DYzQUPwRGwqoAEg5YMwHDBx5Pos39XOF0NVYWZmv+7ywKh6UQVNC5rwYC8YBAgQqxmACg4BndMr2zRdxxyJsSwAvsgJA-VDR2bYtS-H8IDgvt207btkiOR8+xjUd40pVUADFgHsT9oQwh4kJNB8lQYj4o3Q38CJwqAuwCfCxnIbBZF4axsOhXDeN7QjSCfF9ZDfABxD8sK4niLUNTERGk8RJGgeA5EUZQJ3QKdYj0CADFgUxbCMkztDdD10GIOAJCie1lHsmBPWwcsbAAOR1Zz2FZLRlDabAjAgYCAHVAk8+lsA8ryzIsmBgGwDgGjPfEtESxzsAscsrBc4LlFUdRPPsXR9EMUwbPPOz3U8vKAG1-K8ABdKxFSCBziF8Orsty4h0kILLYgw3wwoi6LYv9BLGqS6rYDSjKBtiIb8vSCAWSgQItBSFE0RyLpRsawVhSgOYxjalJJRCHybAANRNfqxoa3rsFanV2oetazAgDbXuM+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

Help using tether with charm-sync

im getting this compiler error: ```ts src/shared/messaging.ts:5:26 - error TS @flamework/core: Unknown type '["object", ["none", ["literal", "none"[], -1]][]] | ["object", (["id", ["optional", ["u8"]]] | ["level", ["optional", ["u8"]]] | ["owner", ["optional", ["blob"]]])[]]' encountered ...

Does anyone have any examples of using something like tether for charm sync

I'm just confused for the manual networking part of charm sync and my project uses tether
Solution:
I use it with serio and charm-payload-converter shared/network.ts ```ts import type { SerializeablePayload } from "@rbxts/charm-payload-converter"...

Flamework Shared Components Help Needed

I created a simple game where you click an object to earn points. I’d like to refactor it using shared components, but I’m not sure how to do it properly. The code works, but not in the best way, so I need someone with more experience to guide me on how to structure it correctly. https://github.com/sdxqw/CandyCraze...

ProfileService and Services

CandyService start faster than PlayerDataService, could someone help me? CandyService.ts https://pastecode.io/s/72064zpd ...

Can you create aliases for flamework decorators

I have this code here: ```ts import { OnStart } from "@flamework/core"; import { Component } from "@flamework/components";...