I'm making a button that will enable or disable a Reactor Laser, when I clicked the button, it doesn't do anything, the output shows no errors so I'm confused.
Code:
01 | local L = game.Workspace.ReactorLasers.ReactorLaser 2. Laer |
02 | local V = true |
03 |
04 | script.Parent.ClickDetector.MouseClick:connect( function () |
05 | if V = = true then |
06 |
07 | L.Transparency = 1 |
08 | script.Parent.BrickColor = BrickColor.Green() |
09 | V = false |
10 |
11 | end |
12 |
13 | if V = = false then |
14 |
15 | L.Transparency = 0 |
I think you see no errors because the script works fine I just think it appears and instantly disappears because there is no wait. So you can change the wait how long you like it to stay but here:
01 | local L = game.Workspace.ReactorLasers.ReactorLaser 2. Laer -- Is this supposed to be Laser? |
02 | local V = true |
03 |
04 | script.Parent.ClickDetector.MouseClick:connect( function () |
05 | if V = = true then |
06 |
07 | L.Transparency = 1 |
08 | script.Parent.BrickColor = BrickColor.Green() |
09 | V = false |
10 | wait( 0.5 ) -- Half a second. |
11 | end |
12 |
13 | if V = = false then |
14 |
15 | L.Transparency = 0 |
Well, first off I didn't know you could define "BrickColor.new()" like that so first i'll change that, second I will change the Clicked function. Try this,
01 | local L = game.Workspace.ReactorLasers.ReactorLaser 2. Laser --I just figured that this would be "laser" not "laer" |
02 | local V = true |
03 |
04 | script.Parent.MouseButton 1 Click:Connect( function () |
05 | if V = = true then |
06 |
07 | L.Transparency = 1 |
08 | script.Parent.BrickColor = BrickColor.new( 'Green' ) |
09 | V = false |
10 |
11 | end |
12 |
13 | if V = = false then |
14 |
15 | L.Transparency = 0 |