Script:
script.Parent.ClickDetector.MouseClick:Connect(function(player) -- Detect player clicked head. if player.PlayerGui.Chats:FindFirstChildOfClass("ScreenGui") == nil then --Here's the problem. print("giving") -- print when the Gui is succesfully given. local GUI = game.Lighting.SpyChatThing:Clone() -- Clone the Gui GUI.Parent = player.PlayerGui.Chats Put Gui in player's Gui GUI.StartTalking:FireClient(player) -- Ignore this else print("Already has the Gui") -- print if the Gui is already in the player's Gui end end)
So, the script checks if the Player is already chatting with the NPC, by seeing if there is a "NPCChatGui". So, at first, it works, but the second time you clik the NPC 's Head, the script thinks the Gui is still active, but it's not.
Here's the script that closes the Gui
local Button = script.Parent:FindFirstChild("Answer") Button.Activated:Connect(function() script.Parent:Destroy() end)