Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

Was "laer" at line one a typo?

2 answers

✓ Accepted answer

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)

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) 

This discussion is preserved as it was. New answers, comments, and votes are closed.