I'm making an npc system but the text is not changing

So, I’m working on a npc system, but the text won’t change.

local ProxPrompt = script.Parent
local Gui = script.Parent.Parent.Parent.Dialogue
local NpcPicture = Gui.MainFrame.DialogueFrame.NpcPicture
local NpcTitle = Gui.MainFrame.DialogueFrame.NpcTitle
local DialogueText = Gui.MainFrame.DialogueFrame.Dialogue
local NextButton = Gui.MainFrame.DialogueFrame.NextButton
ProxPrompt.Enabled = true
ProxPrompt.Triggered:Connect(function(Player)
	local GuiClone = Gui:Clone()
	local Dialogue = GuiClone.MainFrame.DialogueFrame.Dialogue
	GuiClone.Enabled = true
	Player = game.Players:FindFirstChild(Player.Name)
	GuiClone.Parent = Player.PlayerGui
	GuiClone.MainFrame.DialogueFrame.NpcPicture.Image = "rbxassetid://9011713759"
	GuiClone.MainFrame.DialogueFrame.NpcTitle.Text = "Noob"
	GuiClone.MainFrame.DialogueFrame.Dialogue.Text = "Oh, hi...welcome to noobland!"
	if GuiClone then
		ProxPrompt.Enabled = false
		NextButton.MouseButton1Click:Connect(function()
		GuiClone.MainFrame.DialogueFrame.Dialogue.Text = "I'm Bob"
		end)
	end
end)

This is a server script in a proximityPrompt in the npc’s torso
my problem is that after the player hits the next button it does not change the text to “I’m Bob”.
Screenshot 2025-02-13 202819
This is my Gui in the npc to understand the script better.

1 Like

Is this in a local script? If not, then that’s the problem.

it’s a server script in a proximity prompt

when I try it in a local script the whole script does not work

Alright. So I think I may know how to solve you’re problem.

First, instead of cloning the gui, place it under game.StarterGui

I originally had it put it in starter gui but then it did not work, I had to put it in player Gui

oh wait i just realised what you mean sorry

Alright. Your next step is to place a local script under the screen gui.

alright i added a local script

And then use the following code in the local script:

local ProxPrompt = "your proximity prompt from the workspace down"
local Gui = script.Parent
Gui.Enabled = false
local NpcPicture = Gui.MainFrame.DialogueFrame.NpcPicture
local NpcTitle = Gui.MainFrame.DialogueFrame.NpcTitle
local DialogueText = Gui.MainFrame.DialogueFrame.Dialogue
local NextButton = Gui.MainFrame.DialogueFrame.NextButton
ProxPrompt.Enabled = true
ProxPrompt.Triggered:Connect(function(Player)
    if not Player == game.Players.LocalPlayer then return end
	local Dialogue = GuiClone.MainFrame.DialogueFrame.Dialogue
	Gui.Enabled = true
	Gui.MainFrame.DialogueFrame.NpcPicture.Image = "rbxassetid://9011713759"
	Gui.MainFrame.DialogueFrame.NpcTitle.Text = "Noob"
	Gui.MainFrame.DialogueFrame.Dialogue.Text = "Oh, hi...welcome to noobland!"
	ProxPrompt.Enabled = false
	NextButton.MouseButton1Click:Connect(function()
		GuiClone.MainFrame.DialogueFrame.Dialogue.Text = "I'm Bob"
	end)
end)

This should hopefully resolve the issue :grin:

line 10 has an error for some reason

Alright. What does the error say?

ComparisonPrecedence: not X is equivalent to (not X) == Y; consider using X ~= Y, or add parentheses to silence

Oh I think I get it! Small mistake on my end lol.

This should (hopefully) work better:

local ProxPrompt = "your proximity prompt from the workspace down"
local Gui = script.Parent
Gui.Enabled = false
local NpcPicture = Gui.MainFrame.DialogueFrame.NpcPicture
local NpcTitle = Gui.MainFrame.DialogueFrame.NpcTitle
local DialogueText = Gui.MainFrame.DialogueFrame.Dialogue
local NextButton = Gui.MainFrame.DialogueFrame.NextButton
ProxPrompt.Enabled = true
ProxPrompt.Triggered:Connect(function(Player)
    if not (Player == game.Players.LocalPlayer) then return end
	local Dialogue = GuiClone.MainFrame.DialogueFrame.Dialogue
	Gui.Enabled = true
	Gui.MainFrame.DialogueFrame.NpcPicture.Image = "rbxassetid://9011713759"
	Gui.MainFrame.DialogueFrame.NpcTitle.Text = "Noob"
	Gui.MainFrame.DialogueFrame.Dialogue.Text = "Oh, hi...welcome to noobland!"
	ProxPrompt.Enabled = false
	NextButton.MouseButton1Click:Connect(function()
		GuiClone.MainFrame.DialogueFrame.Dialogue.Text = "I'm Bob"
	end)
end)

on line 11 and 19 it says unknown global ‘GuiClone’

Oh. Yeah that was another small mistake of mine.

Hopefully this should work:

local ProxPrompt = "your proximity prompt from the workspace down"
local Gui = script.Parent
Gui.Enabled = false
local NpcPicture = Gui.MainFrame.DialogueFrame.NpcPicture
local NpcTitle = Gui.MainFrame.DialogueFrame.NpcTitle
local DialogueText = Gui.MainFrame.DialogueFrame.Dialogue
local NextButton = Gui.MainFrame.DialogueFrame.NextButton
ProxPrompt.Enabled = true
ProxPrompt.Triggered:Connect(function(Player)
    if not (Player == game.Players.LocalPlayer) then return end
	local Dialogue = Gui.MainFrame.DialogueFrame.Dialogue
	Gui.Enabled = true
	Gui.MainFrame.DialogueFrame.NpcPicture.Image = "rbxassetid://9011713759"
	Gui.MainFrame.DialogueFrame.NpcTitle.Text = "Noob"
	Gui.MainFrame.DialogueFrame.Dialogue.Text = "Oh, hi...welcome to noobland!"
	ProxPrompt.Enabled = false
	NextButton.MouseButton1Click:Connect(function()
		Gui.MainFrame.DialogueFrame.Dialogue.Text = "I'm Bob"
	end)
end)
2 Likes

it works thanks, but question am I going to be able to change text more than 3 times

Yes, if we code it right. I could formulate another script if you tell me the other things you want him to say! And also, you want it to say these after they hit the next button again right?

yes, it works just how I want it. but I’m just asking if I can make him say more than three things. I’m not necessarily saying I want him to say more