Skip to main content

Character Setup

WCS provides a special Character class that acts as a wrapper for a player's character model. You should instantiate this class whenever a character that will take action in combat spawns.

  • To avoid memory leaks always destroy the wrap when the humanoid dies.
character.ts
import { Players } from "@rbxts/services";
import { Character } from "@rbxts/wcs";

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

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