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

How do I get rid of this error when creating type-writer effect?

I was creating a typewriter effect for the GUI when I encountered this problem:

"Players.dangkhoavtnt123.PlayerGui.MonsterKidBubble.MainFrame.Continue.LocalScript:24: attempt to index string with 'Text'"

My Script:

-- Dialogs

local line1 = "* Have you ever thought about\n  a world where everything is\n  exactly the same..."
local line2 = "* Except you don't exist?"
local line3 = "* Everything functions\n  perfectly without you..."
local line4_1 = "* Ha, "
local line4_2 = "ha..."
local line4_3 = "* The thought terrifies me."

-- Instances

local dialog2 = script.Parent.Parent.MonsterKidDialog
local button = script.Parent
local gui = script.Parent.Parent.Parent
local dialogNumber = script.Parent.Value.Value

-- Main script

button.MouseButton1Click:Connect(function()
	dialog2 = ""
	print("dialog passed")
	if dialogNumber == 1 then
		for i = 1, #line1 do
			dialog2.Text = string.sub(line1, 1, i)
			wait(0.04)
		end
		
	elseif dialogNumber == 2 then
		
	
	end
	
	dialogNumber = dialogNumber + 1
end)

Please help me.

1 answer

✓ Accepted answer

Do this:

dialog2.text = dialog2.text .. string.sub(line1,i,i)

Hope this helped!

1 comment

0

thank you for the answer!

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