Please notice: Questline is intended for advanced developers, and requires a decent understanding of the Roblox scripting language.
Questline is a server-sided Roblox module that aids in the creation and tracking of Questlines.
Typically, a Questline is a sequence of objectives the player must accomplish to acheive a goal.
This guide aims to be a quick explaination on how to use Questline.
Getting Started
Questline requires a questId to represent each Questline within the system.
local Questline = require(game.ServerStorage.Questline)
local myQuest = Questline.new("MyQuest")
You can then retrieve a previously created Questline.
local myQuest = Questline.getQuestById("MyQuest")
Adding Objectives
The Objective
property of Questline hosts the various objective types.
local Objective = Questline.Objective
An objective requires it’s own set of parameters; according to it’s function.
local touchBase = Objective.touch(workspace.Baseplate)
Objectives can be grouped together, allowing you to create branching Questlines.
local clickOne = Objective.click(workspace.PartOne)
local clickTwo = Objective.click(workspace.PartTwo)
local chooseOne = Objective.any(clickOne, clickTwo)
Finally, objectives are added to a Questline.
myQuest:AddObjective(touchBase)
Objective Types
Several objective types exist for use in your experience.
Objective Type | Params | Description |
---|---|---|
all |
(...) |
Requires completion of all given objectives. |
any |
(...) |
Requires only one given objective to be complete. |
none |
(...) |
Canceled upon completion of any given objective. |
Objective Type | Params | Description |
---|---|---|
event |
(event, filter) |
Generic, event-based objective. |
score |
(statName, targetValue) |
Tracks the value of a leaderstat. |
timer |
(duration) |
Timed objective. Measured in seconds. |
touch |
(touchPart) |
Touch-based objective. |
value |
(intValue, targetValue) |
Objective based on a playerstat. |
Attaching Events
Questlines have several events associated with them, allowing developers to attach custom behaviour.
function myQuest:OnComplete(player)
print("Yay!,", player)
end
function myQuest:OnCancel(player)
print(player, "failed!")
end
Note:
Each event type can only be assigned to once. Subsequent assignments will overwrite behavior.
Event Types
The following event types are found on a Questline.
BindableEvent | Arguments | Description |
---|---|---|
OnAccept |
(player) |
Fired when player is assigned a Questline for the first time. |
OnAssign |
(player, progress) |
Fired when player is assigned, including subsequent sessions. |
OnCancel |
(player) |
Fired with call to Cancel ; triggered by Objective.none . |
OnComplete |
(player) |
Fired when player has completed the Questline. |
OnProgress |
(player, progress) |
Fired when player has completed an objective. |
Assigning Players
You must register players to assign Questlines. Preferably, when a player first joins an experience.
game.Players.PlayerAdded:Connect(function (player)
Questline.register(player)
end)
Questlines are assigned, for example, when a player touches a part.
workspace.QuestGiver.Touch:Connect(function (hitPart)
local player = game.Players:GetPlayerFromCharacter(hitPart.Parent)
if player and not myQuest:IsConnected(player) then
myQuest:Assign(player)
end
end)
Cleaning Up
When leaving, the player must unregister.
This removes player and cleans up any loose connections.
game.Players.PlayerRemoving:Connect(function (player)
Questline.unregister(player)
end
And that’s it! Now you can start creating your very own Questlines. And remember…
Keep Cool & Be Kind
Questline is made out of , not only for games, but for those that create them. And that’s you!