Quest System / How to disable an old gui?

Hey, I got a quest system that needs fixing, Basically I got a dialouge that gives you the quest, and a dialouge that finishes the quest, Although I don’t know how to balance between them, if you finish the quests, it shows the dialouge that gives you the quest!!! Please help me

print("hey guyssyfuihewfiuhewfiuwf")
local explorer = workspace["QUEST NPCS"].Part
local player = game.Players.LocalPlayer
local beforegui = player.PlayerGui:WaitForChild("QuestDialouge")
local gui = beforegui:WaitForChild("QuestDialogue")
local othergui = player.PlayerGui:WaitForChild("QuestDialougeDone")
local questdone = false

print("beforegui looolll")
local db = false
print("Hey guys whats up today so im going to say hello")
explorer.Touched:Connect(function()
	if not db then
		db = true
		print("2")
		beforegui.QuestDialogue.Visible = true
		print("3")
	gui.NPCName.Text = "Part"
	local chatText = "Hey! I need you to explore this island for me, I need approximately 500 studs explored before I can uncover the mystery of this island, I hear theres a strange thing below here! Will you help me?"
	for i = 1, string.len(chatText) do
		wait(0.025)
		gui.Dialogue.Text = string.sub(chatText, 1, i)
			script.Parent.Parent.Sound:Play()
		end
		gui.Option1.Text = "Sure!"
		gui.Option2.Text = "Nope, I don't want to."
		gui.Option1.Visible = true
		gui.Option2.Visible = true
		print("4")
			db = false
	end
end)

gui.Option1.MouseButton1Click:Connect(function()
	gui.Option1.Visible = false
	gui.Option2.Visible = false
	local chatText = "Thanks man!"
	for i = 1, string.len(chatText) do
		wait(0.025)
		gui.Dialogue.Text = string.sub(chatText, 1, i)
		script.Parent.Parent.Sound:Play()
	end
    wait(2)
	beforegui.QuestDialogue.Visible = false
	game.ReplicatedStorage.QuestRemotes.Walk500Studs.GiveQuest:FireServer()
	wait(2)
	script.Parent.GiveQuest.Enabled = true
end)

gui.Option2.MouseButton1Click:Connect(function()
	gui.Option1.Visible = false
	gui.Option2.Visible = false
	local chatText = "You don't want to? Well.. If you change your mind come to me, I'm waiting for you here."
	for i = 1, string.len(chatText) do
		wait(0.025)
		gui.Dialogue.Text = string.sub(chatText, 1, i)
		script.Parent.Parent.Sound:Play()
	end
	wait(2)
	beforegui.QuestDialogue.Visible = false
	game.ReplicatedStorage.QuestRemotes.Walk500Studs.GiveQuest:FireServer()
	wait(1)
end)

local eb = false

explorer.Touched:Connect(function()
	if player:WaitForChild("Quest"):WaitForChild("CurrentQuest"):WaitForChild("PathFinder"):WaitForChild("QuestDone").Value == true and questdone == true then
		if not eb  then
			eb = true
			beforegui.QuestDialogue.Visible = true
			local chatText = "Whoa! Thats a bunch of information! Thank you"..player.Name.."If thats your name. Goodbye!"
			for i = 1, string.len(chatText) do
				wait(0.025)
				othergui.QuestDialogue.Dialogue.Text = string.sub(chatText, 1, i)
				script.Parent.Parent.Sound:Play()
			end
			wait(2)
			game.ReplicatedStorage.QuestRemotes.Walk500Studs.GivePrize:FireServer()
			beforegui.QuestDialogue.Visible = false
		end
	end
end)

You have explorer.Touched:Connect(function() in your script twice. So, it will run both functions each time expoler:Touched.

I didn’t see anything in the first one that says NOT to show it if SOMETHING is true/false.

So how does the script know if it should run one function or the other?

Put them both into one Touched function, then decide which message to show.

Thank you so much! Even if i havent tested it yet i know for a fact that will work!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.