I'm trying to make a GUI button change to a certain text and change back, but it doesn't go back to the original text! (Fire Laser) There's no output errors.
01 | tparent = script.Parent.Text |
02 | function onButton 1 Down() |
03 | if tparent = = "Fire Laser" then |
04 | print ( "trowowsers" ) |
05 | script.Parent.Text = "Stop Firing" |
06 | else |
07 | script.Parent.Text = "Fire Laser" |
08 | print ( "bowowser" ) |
09 | end |
10 | end |
11 | script.Parent.MouseButton 1 Down:connect(onButton 1 Down) |
Please help me!
I would recommend using MouseButton1Click instead of onButton1Down, and here is what you can do differently.
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | if script.Parent.Text = = "Fire Laser" then |
3 | print ( "trowowsers" ) |
4 | script.Parent.Text = "Stop Firing" |
5 | elseif script.Parent.Text = "Stop Firing" |
6 | script.Parent.Text = "Fire Laser" |
7 | print ( "bowowser" ) |
8 | end |
9 | end ) |
Set tparent = script.Parent, not script.Parent.Text.
This will solve your problem!
01 | tparent = script.Parent |
02 | function onButton 1 Down() |
03 | if tparent.Text = = "Fire Laser" then |
04 | print ( "trowowsers" ) |
05 | tparent.Text = "Stop Firing" |
06 | else |
07 | tparent.Text = "Fire Laser" |
08 | print ( "bowowser" ) |
09 | end |
10 | end |
11 | script.Parent.MouseButton 1 Down:connect(onButton 1 Down) |