Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I need help with making my NPC talk in chat, can somebody help?

I'm trying to make so when a button is clicked and it becomes invisible the NPC talks.

('a' is the name of the NPC)

while game.StarterGui.MainGui.PlayButton.Visible == true do
if game.StarterGui.MainGui.PlayButton.Visible == false then
game:GetService("Chat"):Chat(game.Workspace.a.Head, "EnterTextHere", Enum.ChatColor.White)
wait(2)
end
	end

I have no idea what I'm doing wrong, can somebody help?

(MainGui is the ScreenGui) (PlayButton is the text button)

1 comment

0

when in-game players have a "PlayerGui" instance descended to them, you should be checking this instead of the StarterGui

1 answer

It seems you are have been misinformed from your "experiment" or your brain has been melted from the coding part of the brain, Here, You did while game.StarterGui.MainGui.PlayButton.Visible == true do, this will only work if the playbutton is visible, when it was invisible it stopped and didnt run game.StarterGui.MainGui.PlayButton.Visible == false, So heres your fixed script!

local debounce = false

while true do
wait()
if game.StarterGui.MainGui.PlayButton.Visible == false and debounce == false then
debounce = true
game:GetService("Chat"):Chat(game.Workspace.a.Head, "EnterTextHere", Enum.ChatColor.White)
wait(2)
end
end

1 comment

0

The NPC doesn't chat.

This discussion is preserved as it was. New answers, comments, and votes are closed.