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

Need help, no error shows up while clicking this button and does nothing ??

Asked by 5 years ago

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:

local L = game.Workspace.ReactorLasers.ReactorLaser2.Laer
local V = true

script.Parent.ClickDetector.MouseClick:connect(function()
    if V == true then

        L.Transparency = 1
        script.Parent.BrickColor = BrickColor.Green()
        V = false

    end

    if V == false then

        L.Transparency = 0
        script.Parent.BrickColor = BrickColor.Red()
        V = true

    end

end)

0
Was "laer" at line one a typo? cmgtotalyawesome 1418 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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:

    local L = game.Workspace.ReactorLasers.ReactorLaser2.Laer -- Is this supposed to be Laser?
local V = true

script.Parent.ClickDetector.MouseClick:connect(function()
    if V == true then

        L.Transparency = 1
        script.Parent.BrickColor = BrickColor.Green()
        V = false
wait(0.5) -- Half a second.
    end

    if V == false then

        L.Transparency = 0
        script.Parent.BrickColor = BrickColor.Red()
        V = true

    end

end)
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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,

local L = game.Workspace.ReactorLasers.ReactorLaser2.Laser --I just figured that this would be "laser" not "laer"
    local V = true

    script.Parent.MouseButton1Click:Connect(function()
        if V == true then

            L.Transparency = 1
            script.Parent.BrickColor = BrickColor.new('Green')
            V = false

        end

        if V == false then

            L.Transparency = 0
            script.Parent.BrickColor = BrickColor.new('Red')
            V = true

        end

    end) 

Answer this question