Skip to main content

Applying a status

Applying statuses to characters is very similar to applying abilities. To apply your status to a character in WCS you need to instantiate the status class providing a Character Class Instance.

note

If you want to get the Character Class Instance from a model its applied to you can use a special static method provided by WCS: Character.GetCharacterFromInstance().

Let's make some ability give us a speed boost upon using:

dash.ts
import { Skill, SkillDecorator } from "@rbxts/wcs";
import { SpeedBoost } from "shared/statusEffects/speedBoost";

@SkillDecorator
export class Dash extends Skill {
public OnStartServer() {
const speedBoost = new SpeedBoost(this.Character);
speedBoost.Start(5);
}
}
info

You can safely instantiate status effects on client, but they will not be replicated and will only be visible to client character apis.

note

You can invoke Start() without providing a time limit, but you will have to call Stop() manually.

warning

To prevent memory leaks WCS calls Destroy() on a status effects automatically when it ends. You can set DestroyOnEnd to false inside OnConstructServer() to change that behavior, but you will have to call Destroy() manually.