Skip to main content

Defining a Message

Let's start with defining our first message. In order to do that we need to create a custom method that is going to be a basis for our message. Let's make a simple custom method that calls a print function.

attack.ts
import { Skill, SkillDecorator } from "@rbxts/wcs";

@SkillDecorator
export class Attack extends Skill {
protected printSomething(a: number, b: string) {
print(a,b);
}
}

We defined our custom method called printSomething. Now, all we need to do is call WCS.DefineMessage on that specific function:

note

To define a message in TypeScript you need to use @Message() decorator factory.

attack.ts
import { Skill, SkillDecorator } from "@rbxts/wcs";

@SkillDecorator
export class Attack extends Skill {
@Message({
Type: "Event",
Destination: "Client",
})
protected printSomething(a: number, b: string) {
print(a,b);
}
}

From now, if we call printSomething() on server, it will be passed to a remote event and invoked on client. The following method will be invoked on client:

attack.ts
import { Skill, SkillDecorator } from "@rbxts/wcs";

@SkillDecorator
export class Attack extends Skill {
//...TRUNCATED...
public OnStartServer() {
this.printSomething(1, "hi")
}
}