How do I make a text button change a text label more than once?

  1. What do you want to achieve?

Hi, everyone! I want to create a Roblox visual novel. Like a real visual novel, you click the text box and the text changes. I want to create a text button that changes the text label’s text every time it is clicked.

  1. What is the issue? Include screenshots / videos if possible!
    I only know how to make the text button change the text label’s text once.

Here is the script that I used, but I have no idea how to make the text say something else every time it has been clicked

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve looked through YouTube tutorials and some posts on the forum, but I can’t find one that answers my question. If you have any solutions, I’d be more than grateful to hear them. Thank you for reading!

1 Like

If you want the text label to change to predetermined labels you must define them beforehand as a table for example, then you can take a random item i.e text message. Or you can take input using a TextBox, but that depends on how this ui will be used.

1 Like

you could do smth like this.

local StringTable = {"Hey","Yo","Hyd"} -- Your Sentences
local t = 1
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.TextLabelUI.ImageLabel.TextLabel.Text = StringTable[t]
t += 1
if t == #StringTable then
t = 1
end
end)
2 Likes