Follow up of the same question of what I released an hour ago about changing the text in a text label with a text button. I have tried to compose a series of sentences that get revealed one at a time. It already says "How exciting a new player." and it can only change to the first one of the series of sentences (when the button is pressed) which is "I'm guessing you are here to build Fred." But after when I press the text button again it does not change to the next sentence. What I have so far:
local Button= script.Parent Button.MouseButton1Click:connect (function() script.Parent.Parent.Speech.Text="Im guessing you are here to build Fred." wait (0.1) Button.MouseButton1Click:connect (function() script.Parent.Parent.Speech.Text="Just incase you don't know Fred is a...(nerverse voice) model." wait (0.1) Button.MouseButton1Click:connect (function() script.Parent.Parent.Speech.Text="Firstly we will need to build it a house. This may take some time since it is a house we are building but you know what they say, Rome wasn't built in a day!" end) end) end)
Please help.
Hello there my old friend. There might be better ways of doing this than what I'm about to show you. I think you might be able to use module scripts in a case like this... But because I'm not very familiar with those I'd recommend using variables! Here's an example,
local Button= script.Parent ChatNum = 1 Button.MouseButton1Click:connect (function() local text = script.Parent.Parent.Speech.Text if ChatNum == 1 then ChatNum = 2 text="Im guessing you are here to build Fred." elseif ChatNum == 2 then ChatNum = 3 text="Just incase you don't know Fred is a...(nerverse voice) model." elseif ChatNum== 3 then ChatNum = 4 text="Firstly we will need to build it a house. This may take some time since it is a house we are building but you know what they say, Rome wasn't built in a day Wfvj014!") end end)
This is easy to continue too. I HOPE that helped!
Good luck!
Alright so if you want to make that happen you could just use a BoolValue
or a debounce
as you might call it. You can set it to false when you want one function to happen and you can set it to true when you want the other function to happen. It might be a bit complicated so I will just demonstrate for you as to how I would use it.
local Button = script.Parent -- Variable for the button local Speech = script.Parent.Parent.Speech -- Variable for the TextLabel deb = false -- Variable for the Debounce Button.MouseButton1Click:connect(function() if deb == false then -- Checks if the debounce is false then it will run the rest of the code if it is false. Speech.Text = "Im guessing you are here to build Fred." -- Changes the text. end deb = true -- Changes debounce to true so that the next function can be used. end) Button.MouseButton1Click:connect(function() if deb == true then -- Checks if the debounce is true if it is then it will run the rest of the code. Speech.Text = "Firstly we will need to build it a house. This may take some time since it is a house we are building but you know what they say, Rome wasn't built in a day!" -- Changes the Text. end end)
Well that about concludes what I need to say. I hope it works for you and I hope I managed to help you even if it is a little.
Thank you for reading all the way.
~~KingLoneCat