Hello,

I have a dialogue GUI system that fires a remote event to the client when a part in the workspace is clicked and runs a different dialogue depending on the argument passed through the event.

The first time I click a part, it goes through the dialogue correctly, but the next part I click acts as if I am clicking the buttons of the first function.

A sample of my code in starterGUI is below.

In this example basically what would happen is I go through the dragon dialogue and clicking the button "yes" results in "are you sure you're worthy?" and clicking "no thank you" results in "too bad" and firing another remote event. However, if I then go start the disco dialogue, it provides the correct starting text (the npctext and option1 and option2 text are correct), but clicking on the buttons results in "are you sure you're worthy" or "too bad" and firing the remote event again, as if the function was dragon and not disco.

Any thoughts as to why this is happening?

local function clearGUI()
	dialogueFrame.Visible = false
	options.Visible = false
	continue.Visible = false
	npcText.Text = ""
	option1.Text = ""
	option2.Text = ""
end

local function dragonDialogue()
	
	npcText.Text = "So you want my power, do you?"
	option1.Text = "Yes!"
	option2.Text = "No thank you."
	options.Visible = true
	continue.Visible = false
	dialogueFrame.Visible = true

	option1.MouseButton1Click:Connect(function()
		options.Visible = false
		npcText.Text = "Are you sure you're worthy?"
		wait(1)
		clearGUI()
	end)

	option2.MouseButton1Click:Connect(function()
		options.Visible = false
		npcText.Text = "Too bad!"
		equipAccRemote:FireServer("fireHorns")
		wait(2)
		clearGUI()
	end)
	end

local function discoDialogue()

	npcText.Text = "Why won't anyone dance with me?"
	option1.Text = "You're too creepy."
	option2.Text = "The mood isn't right."
	options.Visible = true
	continue.Visible = false
	dialogueFrame.Visible = true

	option1.MouseButton1Click:Connect(function()
		options.Visible = false
		npcText.Text = "That's not my fault..."
		wait(1)
		clearGUI()
	end)

	option2.MouseButton1Click:Connect(function()
		options.Visible = false
		npcText.Text = "How about this then?"
		wait(1)
		clearGUI()
		delay(2, function()
			npcText.Text = "Maybe not..."
			dialogueFrame.Visible = true
			wait(2)
			clearGUI()
		end)
		changeLights:FireServer(game.workspace.MapLayout.Rooms.Room1.Wall1,Color3.fromRGB(252, 79, 28),5)
	end)

triggerDialogue.OnClientEvent:Connect(function(whatDialogue)
	if whatDialogue == "creepydoll" then
		creepydollDialogue()
	elseif whatDialogue == "leaveDollhouse" then
		leaveDollHouseDialogue()
	elseif whatDialogue == "dragon" then
		dragonDialogue()
	elseif whatDialogue == "disco" then
		discoDialogue()
	elseif whatDialogue == "smokey" then
		smokeyDialogue()
	end
end)

2 comments

0

Are you using the same parts for the options?

0

All of the parts are different. Ie, part1 does FireClient(dragon) and part2 does FireClient(disco) and so on.