Dialogue Script Only Showing First Letter

So, as some may know, I am currently working on a Story game. I have tried a few tutorials online to make a dialogue script, (Since I am bad at GUI scripting) but when I go into the game, it only shows the first letter.

It is supposed to say “Let’s wait for others to load!”

local textLabel = script.Parent
local text

function SoundEffect()
	local sound = Instance.new("Sound", workspace.Sounds.SoundEffects)
	sound.SoundId "rbxassetid://179235828"
	sound.PlaybackSpeed = 1
	sound.Volume = 1
	sound:Play()
	coroutine.resume(coroutine.create(function()
		wait(1)
		sound:Destroy()
	end))
end

function SetText(text)
	text = text
	for i = 1, #text do
		textLabel.Text = string.sub(text,1,i)
		SoundEffect()
		textLabel.TextColor3 = Color3.fromRGB(255,255,255)
		wait(0.05)
	end
end

SetText("Let's wait for others to load!")
wait(10)

It seems there may be a script problem.

I dont see the part where you told your script to show the next letter. Maybe add i + 1 somewhere.

local textLabel = script.Parent
local text

function SoundEffect()
	local sound = Instance.new("Sound", workspace.Sounds.SoundEffects)
	sound.SoundId "rbxassetid://179235828"
	sound.PlaybackSpeed = 1
	sound.Volume = 1
	sound:Play()
	coroutine.resume(coroutine.create(function()
		wait(1)
		sound:Destroy()
	end))
end

function SetText(text)
	text = text
	for i = 1, #text do
		textLabel.Text = string.sub(text,1,i)
		SoundEffect()
		textLabel.TextColor3 = Color3.fromRGB(255,255,255)
		wait(0.05)
		i = i + 1
	end
end

SetText("Let's wait for others to load!")
wait(10)

There you go, a fixed version!

Thank you for the script! I tried putting it into the game, but no luck. Thank you for trying, though!

To get the length of a string, use string.len(text).

Also there’s no need to set the TextColor3 every pass of the loop.

replace this with

sound.SoundId = "rbxassetid://179235828"

:slight_smile:

i dont see any problem here.

local textLabel = script.Parent

function SetText(text)
	text = text
	for i = 1, #text do
		local g = string.sub(text,1,i)
		textLabel.Text = g
		textLabel.TextColor3 = Color3.fromRGB(255,255,255)
		print(g)
		wait(0.1)
	end
end

SetText("Let's wait for others to load!")
wait(10)

or Maybe the textlabel size is too small, so it can only show one text and the others are cut out of the frame

After trying a lot of solutions, this helped the best! Thank you to you and everyone who helped!

1 Like