It only "chat" for one time

I created a GUI where NPC chat in PlayerGui but after I triggered (prompt) for the second time. Anything is not working EVEN the other NPC that I’m tried to triggering.

-- SERVER SCRIPT --
local TalkPromt = script.Parent
local SG = TalkPromt:WaitForChild("TalkGui")

TalkPromt.ObjectText = "Talk with " .. script.Parent.Parent.Parent.Name

TalkPromt.Triggered:Connect(function(Player)
	if not Player.PlayerGui:FindFirstChild("TalkGui") then
	local CloneSG = SG:Clone()
	CloneSG.Parent = Player.PlayerGui
	end
end)

-- CLIENT SCRIPT --
local TalkGui = script.Parent
local Text
local TextLabel

function SoundEffect()
	local Sound = Instance.new("Sound", TalkGui.Frame.TextLabel)
	Sound.Name = "TextSound"
	Sound.SoundId = "http://www.roblox.com/asset/?id=3620844678"
	Sound.PlaybackSpeed = 1
	Sound.Volume = 1
	Sound:Play()
	coroutine.resume(coroutine.create(function()
		wait(1)
		Sound:Destroy()
	end))
end

function setText(word)
	Text = word
	for i=1,#Text do
		TextLabel.Text = string.sub(Text, 1, i)
		SoundEffect()
		TextLabel.TextColor3=Color3.fromRGB(255,255,255)
		wait(0.05)
	end
end

TalkGui:GetPropertyChangedSignal("Parent"):Connect(function()
	if TalkGui.Parent == game.Players.LocalPlayer.PlayerGui then
		TextLabel = TalkGui.Frame.TextLabel
		
		setText("Uhhh... please don't tell the boss about this..")
		wait(0.7)

		setText("Sometimes I dream about him.")
		wait(0.6)

		setText("Anyways ask the boss if I could get a holiday.")
		wait(0.7)
		
		TalkGui:Destroy()
	end
end)

Image on the explorer :
image

Any help is appreciated

Based on the code you provided, it seems that you are creating a chat prompt in the PlayerGui when triggered. However, after triggering it for the second time, nothing is working including other NPCs.

The issue might be that you are not cleaning up the existing chat prompt when triggering it again. When you clone the TalkGui and parent it to PlayerGui, you should also remove the existing TalkGui if it exists.

Here’s an updated version of your code:




-- SERVER SCRIPT --
local TalkPromt = script.Parent
local SG = TalkPromt:WaitForChild("TalkGui")

TalkPromt.ObjectText = "Talk with " .. script.Parent.Parent.Parent.Name

TalkPromt.Triggered:Connect(function(Player)
    local ExistingSG = Player.PlayerGui:FindFirstChild("TalkGui")
    if ExistingSG then
        ExistingSG:Destroy()
    end

local CloneSG = SG:Clone()
CloneSG.Parent = Player.PlayerGui
end)

-- CLIENT SCRIPT --
local TalkGui = script.Parent
local Text
local TextLabel

function SoundEffect()
    local Sound = Instance.new("Sound", TalkGui.Frame.TextLabel)
    Sound.Name = "TextSound"
    Sound.SoundId = "http://www.roblox.com/asset/?id=3620844678"
    Sound.PlaybackSpeed = 1
    Sound.Volume = 1
    Sound:Play()
    coroutine.resume(coroutine.create(function()
        wait(1)
        Sound:Destroy()
    end))
end

function setText(word)
    Text = word
    for i=1,#Text do
        TextLabel.Text = string.sub(Text, 1, i)
        SoundEffect()
        TextLabel.TextColor3=Color3.fromRGB(255,255,255)
        wait(0.05)
    end
end

TalkGui:GetPropertyChangedSignal("Parent"):Connect(function()
    if TalkGui.Parent == game.Players.LocalPlayer.PlayerGui then
        TextLabel = TalkGui.Frame.TextLabel

    setText("Uhhh... please don't tell the boss about this..")
    wait(0.7)

    setText("Sometimes I dream about him.")
    wait(0.6)

    setText("Anyways ask the boss if I could get a holiday.")
    wait(0.7)

    TalkGui:Destroy()
end
end)

In the server script, I added code to check if an existing TalkGui already exists in PlayerGui. If it does, it is destroyed before cloning the new TalkGui. This ensures that only one chat prompt is active at a time.

Let me know if this helps or if you have any further questions!
And warn me polietly if I got it wrong.

Well, seems like really went well but… I want to prevent from spamming (The script only destroys when there’s “TalkGui” and repeat at the start each the ScreenGui destroys)

I currently not having a good mood with jokes + Yeah, you used ChatGPT.