Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Text constant change with text button?

Asked by 8 years ago

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.

0
My answer should work now btw :P User#11440 120 — 8y
0
Why did you join my game? xD You didn't just join so you could down vote did you? Lol. User#11440 120 — 8y
0
no I was waiting for a response and I got board and wait a min you can check when people join your games lordofpoo 22 — 8y
0
Your updated answer still does not work by the way. lordofpoo 22 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

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!

0
Script:11: unexpected symbol near ')' lordofpoo 22 — 8y
0
Thats hilarious!, easy fix. Forgot the end xD I'll edit it. User#11440 120 — 8y
0
Lol keeps turning into Thats hilarious! And it's getting annoying I: User#11440 120 — 8y
0
Your answer still does not work and does not move on from what the text starts from. lordofpoo 22 — 8y
View all comments (3 more)
0
Try it now. User#11440 120 — 8y
0
Sadly no it hasn't worked. lordofpoo 22 — 8y
0
Aw man. Well at least we tried. Sorry I couldn't help you ); User#11440 120 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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

0
This wouldn't work for his situation. This would only work wit User#11440 120 — 8y
0
This would only work twice :P User#11440 120 — 8y
0
Yeah, but he only put examples of two of them... So I was assuming -_- or rather you could be a little creative and make more then one debounce.... And make an if statement saying if debounce == false and this debounce == false then thisdebounce = true.... KingLoneCat 2642 — 8y

Answer this question