Looking for a alternative way of making dialog appear

just looking for an alternative way of doing this instead of having to painstakingly do each letter by hand

I’m new to scripting so any tips will be very appreciated

local sound = script.Parent.Parent.Head.BillboardGui.TextLabel.Sound
local text = script.Parent.Parent.Head.BillboardGui.TextLabel
function onClicked()
	if script.Parent.Parent.Head.BillboardGui.Enabled == false then
		script.Parent.Parent.Head.BillboardGui.Enabled = true
        wait(0.05)
		text.Text = "h..."
		sound:Play()
		wait(0.05)
		text.Text = "he.."
		sound:Play()
		wait(0.05)
		text.Text = "hey."
		sound:Play()
	end
	
end

 script.Parent.MouseClick:connect(onClicked)

What you want is a typewriter effect. Check the hyperlink for info on those (also a video)

Code below is an example of one, but it also replaces the unknown letters with dots (because that’s what your example shows)

local function doDialogue(text)
	local len = #text
	
	for i = 1, #text do
		-- Gets the letters we've already gotten (string.sub), and then adds (len - i) amount of . for the letters that we haven't (string.rep)
		local currentText = string.sub(text, 1, i) .. string.rep(".", len - i)
		
		-- Set the billboard's text to currentText here & play sound

		task.wait()
	end
end
1 Like