Appearance
K.When
Functions
K.When.PlayerJoins
lua
K.When.PlayerJoins(callback: ((Player) -> ())?): ChainOn the server this runs after the player's data has loaded.
K.When.PlayerLeaves
lua
K.When.PlayerLeaves(callback: ((Player) -> ())?): ChainK.When.CharacterSpawns
lua
K.When.CharacterSpawns(callback: ((Player, Model) -> ())?): ChainK.When.PlayerDies
lua
K.When.PlayerDies(callback: ((Player, Model) -> ())?): ChainK.When.PlayerKills
lua
K.When.PlayerKills(callback: ((Player, Instance) -> ())?): ChainRuns for a player who kills someone (a player or NPC) with Combat damage. The chain gets (player, victim).
K.When.QuestCompleted
lua
K.When.QuestCompleted(id: any, callback: ((Player) -> ())?): ChainRuns when a player completes a quest (any quest, or only id).
K.When.RoundStarts
lua
K.When.RoundStarts(callback: ((Player) -> ())?): ChainRuns for every player in a round when it starts (needs K.Rounds.Define).
K.When.RoundEnds
lua
K.When.RoundEnds(callback: ((Player, any) -> ())?): ChainRuns for every player who played a round when it ends. The chain gets (player, result).
K.When.PlayerWinsRound
lua
K.When.PlayerWinsRound(callback: ((Player) -> ())?): ChainRuns for each winner of a round.
Methods on chain
chain:Run
lua
chain:Run(callback: (Player?, ...any) -> boolean?)Runs your own function with the player. Return false from it to skip the actions after it.
chain:Give
lua
chain:Give(name: string, amount: number?)chain:Take
lua
chain:Take(name: string, amount: number?, failMessage: string?)Takes currency. If the player can't afford it, shows failMessage (if given) and stops.
chain:Action
lua
chain:Action(name: string, ...: any)Runs one of your K.Action actions for the player, with its hooks. If it fails, the player is told why and the chain stops.
chain:GiveItem
lua
chain:GiveItem(item: string, amount: number?, inventory: any)Gives an item. If it doesn't fit, tells the player and stops.
chain:TakeItem
lua
chain:TakeItem(item: string, amount: number?, failMessage: string?, inventory: any)Takes an item. If the player doesn't have enough, shows failMessage (if given) and stops.
chain:Damage
lua
chain:Damage(amount: number)Damages the player (through K.Combat, so hooks and Defense apply).
chain:Heal
lua
chain:Heal(amount: number)chain:Buff
lua
chain:Buff(stat: string, options: { [string]: any })Adds a stat modifier, e.g. :Buff("WalkSpeed", { Multiply = 2, Duration = 5 }). Without an Id, one Id per chain is used, so triggering again refreshes the buff.
chain:StartQuest
lua
chain:StartQuest(id: string)Starts a quest. If it can't start (already done, requirements...), the actions after it are skipped.
chain:ClaimQuest
lua
chain:ClaimQuest(id: string)Gives the rewards of a finished quest that has AutoClaim = false (like handing it in to an NPC).
chain:QuestEvent
lua
chain:QuestEvent(name: string, amount: number?)Moves "Event" quest objectives with this Event name forward.
chain:Reward
lua
chain:Reward(bundle: { [string]: any })Gives a reward bundle, e.g. :Reward({ Coins = 100, Items = { Sword = 1 } }).
chain:Prompt
lua
chain:Prompt(name: string)Opens Roblox's purchase window for a pass, product, subscription or Premium.
chain:RequireOwned
lua
chain:RequireOwned(name: string, failMessage: string?)Continues only for players who own the pass (or are subscribed / Premium / boosted). Everyone else gets the purchase window (when it can be bought) and the chain stops.
chain:Step
lua
chain:Step(funnel: string, step: string)Logs an Analytics funnel step for the player.
chain:Say
lua
chain:Say(text: string, options: { [string]: any }?)Shows a message. {player} in the text becomes the player's name.
chain:Kill
lua
chain:Kill(): Chainchain:Respawn
lua
chain:Respawn(): Chainchain:Teleport
lua
chain:Teleport(target: any)Moves the player to a Part, Model, Vector3 or CFrame.
chain:Award
lua
chain:Award(badgeId: number)Awards a Roblox badge. Runs in the background, so it never holds up the chain.
chain:Wait
lua
chain:Wait(seconds: number)chain:Hide
lua
chain:Hide(seconds: number?)Hides the part (for everyone, when used on the server). With seconds, it comes back after that long.
chain:Show
lua
chain:Show(): Chainchain:Remove
lua
chain:Remove(): ChainDeletes the part or model.
chain:Then
lua
chain:Then(): ChainDoes nothing; it only makes chains read better.
chain:Once
lua
chain:Once(): ChainOnly ever runs once, for the first player.
chain:OncePerPlayer
lua
chain:OncePerPlayer(): ChainRuns once for each player.
chain:Stop
lua
chain:Stop()Stops listening for the event.
Generated from
src/Corode/When.luau.
