How would I make every WORD appear after a wait time

Hi im making a talking system to a npc.
How would I make every WORD appear after a wait time.
It writes like a type write at the moment so it does every letter, i’d prefer every word instead any ideas?

Line1 = “Help,”…“<font color="rgb(255,0,0)"> 10 Bandits are attack, ”…“are attacking can you help me.”

for i = 1,string.len(Line1),1 do
Sounds:FindFirstChild(“TextSound”):Play()
PromptGUI.QuestFrame.QuestInfoText.Text = string.sub(Line1,0.5,i)
wait(0.05)
end

Maybe try putting all the words in a table and using an in pairs loop?

Split the string into words using string.split, then iterate over the returned array table using ipairs to show the text.

local TextSound = Sounds:WaitForChild("TextSound") -- store the TextSound here so you aren't calling FindFirstChild everytime you want to display a word
local Line1 =  "Help, 10 Bandits are attacking, can you help me?" -- use local variables please
local Words = string.split(Line1, " ") -- split the string into segments separated by spaces, returns an array

-- ensure (PromptGUI.QuestInfoText.Text == "") before doing this
for _,Word in ipairs(Words) do -- ipairs should be used because pairs isn't garuanteed to iterate over the array in order
	TextSound:Play()
	PromptGUI.QuestInfoText.Text ..= " " .. Word -- compound concatentate operator
	wait(0.05)
end
-- intended output (haven't actually tested this, this is just what *should* happen

--> Help,
--> Help, 10
--> Help, 10 Bandits
--> ...
--> Help, 10 Bandits are attacking, can you help
--> Help, 10 Bandits are attacking, can you help me?

Edit: Replied to the wrong person, sorry (meant to reply to the topic)

2 Likes