I want to make a system where you click on text and it can progress the dialouge, but I don’t want to have to put a function for every time I want to know if the player has clicked the dialouge.
What I don’t want:
button.MouseButton1Click:Connect(function()
button.Text = "indeed i should head for a run"
button.MouseButton1Click:Connect(function()
button.Text = "time to head for a run now"
end)
end)
The simplest solution I can think of would be to have a table of dialogues and a counter value that increases every time the player clicks. e.g:
local dialogueTable = {"indeed i should head for a run", "time to head for a run now"}
local counter = 1
button.MouseButton1Click:Connect(function()
button.Text = dialogueTable[counter]
counter++
end)
What if I wanted to check if the player has pressed click to continue to change something else that isn’t the text, without having to constantly check the counter?
For example: I want to put a proximityprompt in front of the player once they have pressed click to continue for 2 pieces of dialouge.
local dialogueTable = {"indeed i should head for a run", "time to head for a run now"}
local counter = 1 --1 = 0 times clicked, 2 = 1 time clicked
button.MouseButton1Click:Connect(function()
counter =+ 1 -makes the count +1
button.Text = dialogueTable[counter] --sets the text
if counter == 3 then --if the player has clicked two times
--do stuff
end
end)
Note that the --do stuff section will only happen one time, which is probably what you are looking for.