How to make a Quest System Part 2

~ PART 2 OF QUEST TUTORIAL SYSTEM ~

This part deals with the quest GUI.

NOTE: Sorry for the delayed post. I had issues with school recently.

If you haven’t read the other parts then here is the link:
~Part1 - How to make a Quest System

Hi! Welcome to part 2 of the quest tutorial system. Today I’m gonna show you how to add a quest GUI and how to add quests to it. Let’s begin! :smiley:

First, get this GUI I made: Quests GUI - Roblox
Feel free to make changes to the GUI but please don’t change any of the objects’ name and order. If you do, something may go wrong.

This is how your StarterGui should look like.
image

Also, move the TempQuestFrame to the ReplicatedStorage

Add a local script to the StarterGui named GUIHandler.
This is the code:

local event = game.ReplicatedStorage:WaitForChild("AddQuest")
local questsGUI = script.Parent:WaitForChild("Quests")
local questFrameTemp = game.ReplicatedStorage:WaitForChild("TempQuestFrame")
local mainFrame = questsGUI:WaitForChild("BGFrame")
local questsFrame = mainFrame:WaitForChild("QuestsFrame")

local function makeFrame(questName, parentName, number)
	local clone = questFrameTemp:Clone()
    clone.Name = questName.Name
	local counter = clone:WaitForChild("Counter")
	local NPCname = clone:WaitForChild("NPCName")
	if parentName == nil then
		NPCname.Text = ""
	else
		NPCname.Text = tostring(parentName)
	end
	local counterText = counter:WaitForChild("CounterText")
	counterText.Text = number.."/"..number
	local QuestName = clone:WaitForChild("QuestName")
	QuestName.Text = tostring(questName.Name)
	clone.Parent = questsFrame
end

event.OnClientEvent:Connect(function(questName, parentName, number)
	if mainFrame.Visible == false then
		mainFrame.Visible = true
	end
	makeFrame(questName, parentName, number)
end)

The event variable is the remote event we made that is located in the ReplicatedStorage. The questsGUI variable is the GUI I gave and should be in StarterGui. The questFrameTemp variable is a reference Frame to make a quest frame. The mainFrame and the questsFrame are descendants of the questFrameTemp variable. The function makeFrame makes a clone of the questFrameTemp and changes it’s descendants to match the parameters we sent to the function. The if statement inside, if parentName == nil, checks if the parentName we sent through the client is nil. If it’s nil then it sets the text of the text label named “NPCname” to a blank value, which is " ". But if it’s not nil then it sets the text to the parentName variable. After the changes, the function parents the clone to the scrolling frame named questsFrame to make the clone visible. Once we fire the event variable, the thread inside event.OnClientEvent runs. Inside it is an if statement that checks if the mainFrame is visible. If it’s not, then it makes it visible. After that, it runs the makeFrame function.

Let’s test it out!
RESULT VIDEO:

As you can see in the video, it works just as planned but there’s a problem. If we accepted the quest, we can still accept it. Thus making more frames in the scrolling frame. We’re going to solve that problem once we go to the DataStore part which is probably part 4 or 5. Anyways, thanks for going through my tutorial! I hope you learned something in this tutorial. If you do, please give a like and feel free to give a feedback. Stay tuned for part 3! :smiley:

16 Likes

this isnt a tutorial its more of a resource because in a tutorial u need to explain the code you made

2 Likes

Isn’t this an explanation? or do I need to explain it more.

3 Likes

Good job, but don’t let the players get the same quest if they’ve got it already

2 Likes

Thanks for the feedback! I mentioned that I would fix that problem in part 4 or part 5.

3 Likes