Define The Behavior
Now, after we created our first ability we need to define its custom behavior. Right now, lets make it print something when player starts the ability and add a small cooldown for it:
- TypeScript
- Luau
attack.ts
import { Skill, SkillDecorator } from "@rbxts/wcs";
@SkillDecorator
export class Attack extends Skill {
public OnStartServer() {
print("Hi, attack just started!");
this.ApplyCooldown(3) // 3 second cooldown
}
}
attack.lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WCS = require(ReplicatedStorage.WCS)
local Attack = WCS.RegisterSkill("Attack")
function Attack:OnStartServer()
print("Hi, attack just started!")
self:ApplyCooldown(3) -- 3 second cooldown
end
return Attack
Okay! That's great, but let's start our ability!