Questline: A Free Quest Creation Module

Questline

[ Demo ] [ Docs ] [ Source ]

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.

:rocket: 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")

:white_check_mark: 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.

:bell: 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

:bulb: 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.

:magnet: 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)

:poop: 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…

:sunglasses: Keep Cool & Be Kind

Questline is made out of :heart:, not only for games, but for those that create them. And that’s you!

77 Likes

Awesome definitely using for my next project

4 Likes

How would you use the data saving, when I try it, also using the demo, it doesn’t save? Need help with that please.

1 Like

i dont see the video of demo there only the demo place, u should add it so people can see it.

2 Likes

Absolutely incredible and definitely going to use this or at least study this framework, makes a lot of things easier on design

2 Likes

You made this on a very beautiful way keep it up

1 Like

Thanks! Let me know if you run into any issues.

1 Like

This module is impressive, but from my experience, it seems to function best with static objects already present in the workspace. However, when dealing with dynamically created or cloned objects, its support seems limited.

1 Like

How can it be fixed to work dynamically? Readimg from a table that allows dynamic quest data ?

1 Like

Thanks for the feedback. That’s definitely an issue that needs to be addressed. I’ve not had too much free time recently due to a new job, but I have been playing around with code structure to make the project more manageable.

1 Like

While looking through the code I noticed that there was an error in line 71, where “comp” should have been “compare”, so that the custom function gets called. Other than that, great module saved me a lot typing.

Is the documentation still available for this module. excellent module by the way for developers to add on to as well!

I’m updating the library and just released the source code here. I still have a lot of work to do; including documentation and examples.

I hope to update this post soon to reflect the changes. Until then, feel free to look around the repo, and thanks for your support.

1 Like

How can I download the system?

I just uploaded the new version here.
Just download the file and import into ServerStorage.

Why not upload it through Roblox?

Can you make a new Questline with new Questline Module and Quest Cancel?

Just released a major update, including a revamp of the underlying code. This will make it easier to modify and extend.

It’s still a work in progress, but progress is still being made.

Cool, I checked out the demo place.

What other features will you be adding?

Any UI / GUI that shows a list of quests done, quests to do and show like locked future ones ?

Maybe even a hover over that then has a description of why to do the quest?..
Like
Golden Key = desc ‘Find the the Golden Key to the North, which will allow you to unlock the tunnel door.’

Thanks for making this!

Those are great ideas. My focus for now will be to integrate datastores and further documentation and intellisense.

At this point, the logging system is basic for sure. I hope to work on that more when I have the free time.