Not Detecting When A Text Buttons Clicked

Hello! I’m making a system to interact with characters (ex. talk to them, get assigned quests, etc.) around them map. For the quest part, I am trying to detect when the player clicks on a text button (the text button is in StarterGUI and the script to detect this is in a folder under StarterCharacterScripts.) However, when I do click on the text button, it does not register and when I put “print” after MouseButton1Click, nothing prints.

local Players = game.Players

Players.PlayerAdded:Connect(function(plr)
		
		if plr:FindFirstChild("Quest Tracker").Value == true then
			return
		end
		
		local UI = plr.PlayerGui.Dialogue
		local Info = plr.PlayerGui.Dialogue["Who are you?"]
		local Quest = plr.PlayerGui.Dialogue.Quest
		local NPCNAME = "Pheonix"
		UI.NPCname.Text = NPCNAME
		
		
		Info.MouseButton1Click:Connect(function()
			print("info")
			local Dialogue = "Yo, names Pheonix."
			local Dialogue2 = "Info about me here."
			local Dialogue3 = "(More info about me here.)"
			Quest.Text = "Next"
			for i = 1, #Dialogue do
				UI.Dialogue.Text  = string.sub(Dialogue, 1, i)
				task.wait(0.05)
			end

			repeat task.wait()
			until UI.Value.Value == true

			for i = 1, #Dialogue2 do
				UI.Dialogue.Text  = string.sub(Dialogue2, 1, i)
				task.wait(0.05)
			end

			repeat task.wait()
			until UI.Value.Value == true

			for i = 1, #Dialogue3 do
				UI.Dialogue.Text  = string.sub(Dialogue3, 1, i)
				task.wait(0.05)
			end	
		end)
		
		Quest.MouseButton1Click:Connect(function()
			print("quest")
			local Dialogue = "I need you to do some work for me. You see, my boss told me to kill those thugs that are behind you."
			local Dialogue2 = "They caused him some trouble, you know, owe him money, the usual."
			local Dialogue3 = "Whatever, I'll cut to the chase. I need you to take out 10 of them and I'll give you a reward."
			Quest.Text = "Next"
			
			for i = 1, #Dialogue do
				UI.Dialogue.Text  = string.sub(Dialogue, 1, i)
				task.wait(0.05)
			end

			repeat task.wait()
			until UI.Value.Value == true

			for i = 1, #Dialogue2 do
				UI.Dialogue.Text  = string.sub(Dialogue2, 1, i)
				task.wait(0.05)
			end

			repeat task.wait()
			until UI.Value.Value == true

			for i = 1, #Dialogue3 do
				UI.Dialogue.Text  = string.sub(Dialogue3, 1, i)
				task.wait(0.05)
			end	
		end)
end)
3 Likes

try putting the script as a localscript inside the gui, instead of doing the Players.PlayersAdded thing you could just do this

local plr = game.Players.LocalPlayer

if plr:FindFirstChild("Quest Tracker").Value == false then

	local UI = plr.PlayerGui.Dialogue
	local Info = plr.PlayerGui.Dialogue["Who are you?"]
	local Quest = plr.PlayerGui.Dialogue.Quest
	local NPCNAME = "Pheonix"
	UI.NPCname.Text = NPCNAME

	Info.MouseButton1Click:Connect(function()
		print("info")
		local Dialogue = "Yo, names Pheonix."
		local Dialogue2 = "Info about me here."
		local Dialogue3 = "(More info about me here.)"
		Quest.Text = "Next"
		for i = 1, #Dialogue do
			UI.Dialogue.Text  = string.sub(Dialogue, 1, i)
			task.wait(0.05)
		end

		repeat task.wait()
		until UI.Value.Value == true

		for i = 1, #Dialogue2 do
			UI.Dialogue.Text  = string.sub(Dialogue2, 1, i)
			task.wait(0.05)
		end

		repeat task.wait()
		until UI.Value.Value == true

		for i = 1, #Dialogue3 do
			UI.Dialogue.Text  = string.sub(Dialogue3, 1, i)
			task.wait(0.05)
		end	
	end)

	Quest.MouseButton1Click:Connect(function()
		print("quest")
		local Dialogue = "I need you to do some work for me. You see, my boss told me to kill those thugs that are behind you."
		local Dialogue2 = "They caused him some trouble, you know, owe him money, the usual."
		local Dialogue3 = "Whatever, I'll cut to the chase. I need you to take out 10 of them and I'll give you a reward."
		Quest.Text = "Next"

		for i = 1, #Dialogue do
			UI.Dialogue.Text  = string.sub(Dialogue, 1, i)
			task.wait(0.05)
		end

		repeat task.wait()
		until UI.Value.Value == true

		for i = 1, #Dialogue2 do
			UI.Dialogue.Text  = string.sub(Dialogue2, 1, i)
			task.wait(0.05)
		end

		repeat task.wait()
		until UI.Value.Value == true

		for i = 1, #Dialogue3 do
			UI.Dialogue.Text  = string.sub(Dialogue3, 1, i)
			task.wait(0.05)
		end	
	end)
end

(i did change some things, if it doesn’t work like you wanted it to tell me)

2 Likes

Have you tried printing Info to see if it exists or if youre calling it right?

Can you also try MouseButton1Down instead of click? its a little more universal.

1 Like

Can’t you do the Quest.Activated event instead?

2 Likes

If you aren’t getting any errors I’d suggest double checking what this value is at the very start via print statement. There might be a chance that the value of that object is false when they first get in, causing the rest of the code to not be run.

1 Like

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