I'm able to make the gui appear when a player responds to the NPC, but I can't seem to figure out how to make the gui disappear automatically when a player walks away from the conversation.
Dialog = script.Parent
Dialog.DialogChoiceSelected:connect(function(player,dialog)
local ShopScreen = script.Parent.ShopScreen
if dialog.Name == "OpenShop" then
ShopScreen:Clone().Parent = player.PlayerGui
local ShopScreenClone = player.PlayerGui.ShopScreen
Background = ShopScreenClone.Background
Features = ShopScreenClone.Features
for i, child in pairs(ShopScreenClone:GetChildren()) do
child.Visible = true
end
Background:TweenSizeAndPosition(UDim2.new(0, 400, 0, 400), UDim2.new(0.292, 0,0.081, 0), "In", "Quad", 2)
wait(0.5)
Features:TweenPosition(UDim2.new(0.294, 0,0.104, 0), "Out", "Quad", 0.5)
end
end)
if Dialog.InUse == false then
Background:TweenSizeAndPosition(UDim2.new(0, 0, 0, 0), UDim2.new(0.292, 0,0.081, 0), "In", "Quad", 2)
Features:TweenPosition(UDim2.new(-1, 0,0.104, 0), "Out", "Quad", 0.5)
end

3 comments
Not a request site!
Could check magnitude of player to npc, and if they are out of a max range, then close the dialog.
If I were you, I wouldn't use DialogChoiceSelected. It doesn't work in FE games at all.