The second part of my dialogue script won't work

Local Script:

local ModuleScript = require(script.ModuleScript)
local Frame  = script.Parent.Frame
local TextLabel = script.Parent.TextLabel
local Prox = game.Workspace.Part.ProximityPrompt
local Option1 = script.Parent.Option1
local Option2 = script.Parent.Option2
Option1.Transparency = 1
Option2.Transparency = 1
Frame.Transparency = 1
TextLabel.Transparency = 1
Option1.Interactable = false
Option2.Interactable = false

local function typeWrite(object,text,writeDelay)
	
	for i = 1,#text,1 do
		object.Text = string.sub(text,1,i)
		wait(writeDelay)
	end
	
end



Prox.Triggered:Connect(function(plr)
	
	if plr then
		Prox.Enabled = false
		plr.Character.Humanoid.JumpPower = 0
		plr.Character.Humanoid.WalkSpeed = 0
		Frame.Transparency = 0
		TextLabel.Transparency = 0
		
		typeWrite(TextLabel,ModuleScript.FirstReply["Npc First Reply"],0.03)
		task.wait(2)
		Option1.Transparency = 0
		Option2.Transparency = 0
		Option1.Interactable = true
		Option2.Interactable = true
			typeWrite(Option1,ModuleScript.FirstReply["First Two Replies"].FirstBox,0.03)
			typeWrite(Option2,ModuleScript.FirstReply["First Two Replies"].SecondBox,0.03)
	end
	
	task.wait(1.5)
	Option1.MouseButton1Click:Connect(function()
		if Option1.Transparency == 0   and  Option1.Text ==  "Doing Good" then
			Option1.Transparency = 1
			Option2.Transparency = 1
			Option1.Interactable = false
			Option2.Interactable = false
			typeWrite(TextLabel,ModuleScript.SecondReply["Npc Second Reply"],0.03)
			task.wait(1)
			Option1.Transparency = 0
			Option2.Transparency = 0
			Option1.Interactable = true
			Option2.Interactable = true
			--typeWrite(Option1,ModuleScript.SecondReply["Second Two Replies"].FirstBox)
		
			if Option2.MouseButton1Click  then
				typeWrite(Option1,ModuleScript.SecondReply["Second Two Replies"].FirstBox,0.03)
				typeWrite(Option2,ModuleScript.SecondReply["Second Two Replies"].SecondBox,0.03)
			end
			
		end
		
		
		
	end)
	
	Option2.MouseButton1Click:Connect(function()
	
		if Option2.Transparency == 0 and Option2.Text == "Great"  then
			Option1.Transparency = 1
			Option2.Transparency =	1
			Option1.Interactable = true
			Option2.Interactable = true
			typeWrite(TextLabel,ModuleScript.SecondReply["Npc Second Reply"],0.03)
			task.wait(1)
			Option1.Transparency = 0
			Option2.Transparency =	0
			Option1.Interactable = true
			Option2.Interactable = true
			--typeWrite(Option2,ModuleScript.SecondReply["Second Two Replies"].SecondBox)
			
			if Option1.MouseButton1Click then
				typeWrite(Option1,ModuleScript.SecondReply["Second Two Replies"].FirstBox,0.03)
				typeWrite(Option2,ModuleScript.SecondReply["Second Two Replies"].SecondBox,0.03)
			end
		end

		
	end)
	if Option1.Text == "Sure" then
		Option1.MouseButton1Click:Connect(function()
		Option1.Visible = false 
		Option2.Visible = false
		Option1.Interactable = false
		Option2.Interactable = false
		Frame.Transparency = 1
		TextLabel.Transparency = 1
		end)
	end
	


	if Option2.Text == "Nah"  then 
		Option2.MouseButton1Click:Connect(function()
		Option1.Visible = false
		Option2.Visible = false
		Option1.Interactable = false
		Option2.Interactable = false
		Frame.Transparency = 1
		TextLabel.Transparency = 1
		end)
	end

	
	
end)

Module Script:

local module = {}

module.FirstReply = {
	
	["Npc First Reply"] = "Hey, how's  it going.",
	
	
  ["First Two Replies"] = {
  ["FirstBox"] = "Doing Good",	
  ["SecondBox"] = "Great"	
		
  },
	
	
}

module.SecondReply = {
	
	["Npc Second Reply"]  = "Want A Free Sword",
	
	["Second Two Replies"] ={
		["FirstBox"] = "Sure",
		["SecondBox"] = "Nah"
	}
	
	
}

return module

When I click on the first part of the dialogue it works and makes me move on to the second part of the dialogue its when I try to click on a option it just won’t do anything could someone help me fix this

1 Like
if Option1.MouseButton1Click then
				typeWrite(Option1,ModuleScript.SecondReply["Second Two Replies"].FirstBox,0.03)
				typeWrite(Option2,ModuleScript.SecondReply["Second Two Replies"].SecondBox,0.03)
			end

This is the problem I believe, using an if statement on an event doesn’t work. Connect exists for a reason. Use connect to check for that.
Same with option1.Mousclick if statement.

1 Like

The problem might be in the conditional checks inside the MouseButton1Click event handlers. Currently, the conditions might not be evaluated as expected, leading to the event handlers not being triggered correctly.

Replace

if Option1.MouseButton1Click then

With

Option1.MouseButton1Click:Connect(function()

And

if Option2.MouseButton1Click then

with:

Option2.MouseButton1Click:Connect(function()
1 Like

I’ve tried these and they still give me the same result

1 Like

Is your proximity prompt object running into errors? Because it might not’ve loaded on the client yet, consider using a waitforchild.

I have not talked in this topic in a while but I just want you to know that I fixed it so I am just going to make your suggestion the solution.

Uh you marked yourself the solution…

Ooppsie I made a little mistake