I'm trying to make a script of dialogue with a part of it that will only activate when you click on the required thing. In this game, you're a babysitter, and the parents ask you to look for the baby around the house, what I want the script to do is to make them silent until you click on the child, when you click on him, they're supposed to continue their dialogue.
Here's what the script looks like so far: while true do
wait()
script.Parent.Text = "We made it! Wait, the truck has left already?!" wait(15) script.Parent.Text = "Oh, there you all are. Me and my wife were so impatient to go to the luxury restaurant." wait(5) script.Parent.Text = "Be careful, you wonderful people. Our son is naughty, he can annoy you in any way, and he often throws tantrums." wait(7) script.Parent.Text = "Speaking of your son, where is he?" wait(5) script.Parent.Text = "He must be playing hide'n seek with his imaginary friend once again." wait(5) script.Parent.Text = "SON, COME DOWN HERE! YOUR BABYSITTERS ARE HERE!" wait(5) script.Parent.Text = "Son?" wait(5) script.Parent.Text = "What a naughty boy..." wait(5) script.Parent.Text = "Go in the house and look for our son, click on him when you find him!" <- This is the part where they're supposed to keep quiet until you click on the son script.Parent.Text = "Oh, there he is! Thanks for finding him! We'll be going now!"
end
The part where they're supposed to keep quiet until you click on their son is between the "Go in the house and look for our son..." text and the "Oh, there he is!" text. What script can I use to make the dialogue stop until you click on the son?
Use the MouseClick
event of ClickDetector
to do this. But, instead of connecting function, just :Wait()
for the event.
Like so
script.Parent.Text = "some text" click_detector.MouseClick:Wait() script.Parent.Text = "text after clicking"
event:Wait()
yields the current thread until event
is fired.