Skip to main content

Applying abilities

To apply your ability to a character in WCS you need to instantiate an ability 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().

info

If you want to apply/remove multiple abilities at the same time, consider looking into movesets.

Let's modify our character file/script to apply our ability:

character.ts
import { Players } from "@rbxts/services";
import { Character } from "@rbxts/wcs";
import { Attack } from "shared/attack";

Players.PlayerAdded.Connect((Player) => {
Player.CharacterAdded.Connect((CharacterModel) => {
// apply the wrap when character model gets created
const WCS_Character = new Character(CharacterModel);

// apply our freshly made skill
new Attack(WCS_Character);

// destroy it when humanoid dies
const humanoid = CharacterModel.WaitForChild("Humanoid") as Humanoid;
humanoid.Died.Once(() => WCS_Character.Destroy());
});
});
note

In order to remove an ability from a character you got to call Destroy() on its instance. To get the instance from the name/constructor you can use the following WCS APIs: Character:GetSkillFromConstructor(), Character:GetSkillFromString()