Create a status effect
Status Effects in WCS are classes that represent side-effects. The usage is very similar to skills, you also define their behavior by overriding default methods. They also provide useful tooling for manipulating roblox humanoid stats, e.g, setting the walkspeed when the player should be stunned.
Let's register a simple status effect and make it print something when started:
- TypeScript
- Luau
attack.ts
import { StatusEffect, StatusEffectDecorator } from "@rbxts/wcs";
@StatusEffectDecorator
export class Stun extends StatusEffect {
public OnStartServer() {
print("Stun just started!")
}
}
attack.lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WCS = require(ReplicatedStorage.WCS)
local Stun = WCS.RegisterStatusEffect("Stun")
function Stun:OnStartServer()
print("Stun just started!")
end
return Stun