How to disable a dialog

So basically I want to temporarily disable a dialog so that now one can click it. At the moment I am using this script

local Dialog = NPC.Head.Dialog:Clone()
NPC.Head.Dialog:Destroy()
...
Dialog.Parent = NPC.Head

However this is how i’m detecting when someone presses it

local player = game.Players.LocalPlayer

player.PlayerGui:WaitForChild("OrderGui").Enabled = false

game.Workspace.WorkingNPCs.NPC1.Head.Dialog.DialogChoiceSelected:Connect(function(Player, Choice)
	print("Selected A Choice")
	if player == Player and Choice.Name == "DisplayOrderGui" then
		print("Displaying Gui")
		player.PlayerGui.OrderGui.Enabled = true
		player.PlayerGui.OrderGui.CurrentNPC.Value = game.Workspace.WorkingNPCs.NPC1
	end
end)

So when the script deletes it, the local script won’t work when I readd it which is a problem. So, Is there any way I can disable the dialog or use a better way for detecting input?

I figured it out, I used this local script

local player = game.Players.LocalPlayer

player.PlayerGui:WaitForChild("OrderGui").Enabled = false

game.Workspace.WorkingNPCs.NPC1.Head.Dialog.DialogChoiceSelected:Connect(function(Player, Choice)
	print("Selected A Choice")
	if player == Player and Choice.Name == "DisplayOrderGui" then
		print("Displaying Gui")
		player.PlayerGui.OrderGui.Enabled = true
		player.PlayerGui.OrderGui.CurrentNPC.Value = game.Workspace.WorkingNPCs.NPC1
	end
end)

game.Workspace.WorkingNPCs.NPC1.Head.ChildAdded:Connect(function(child)
	local Head = game.Workspace.WorkingNPCs.NPC1.Head:FindFirstChild("Dialog")
	if Head then
		if child == Head then
			Head.DialogChoiceSelected:Connect(function(Player, Choice)
				print("Selected A Choice")
				if player == Player and Choice.Name == "DisplayOrderGui" then
					print("Displaying Gui")
					player.PlayerGui.OrderGui.Enabled = true
					player.PlayerGui.OrderGui.CurrentNPC.Value = game.Workspace.WorkingNPCs.NPC1
				end
			end)
		end
	end
end)
2 Likes