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

Small script for computer button is not working, can anyone help?

I'm trying to make a small script where you click the computer button to turn it on. It's basically not much, it only changes the button color and the decals transparency, that's all. But for some reason it's not working.

Here's the script:

function onClicked()
	
	if script.Parent.Parent.Screen.Decal.Transparency == 1 then
		script.Parent.BrickColor = "LimeGreen"
		script.Parent.Parent.Screen.Decal.Transparency = 0
	else
		script.Parent.Parent.Screen.Decal.Transparency = 1
		script.Parent.BrickColor = "Crimson"
	end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked()

1 answer

✓ Accepted answer
function onClicked()

    if script.Parent.Parent.Screen.Decal.Transparency == 1 then
        script.Parent.BrickColor = BrickColor.new("LimeGreen")
        script.Parent.Parent.Screen.Decal.Transparency = 0
    else
        script.Parent.Parent.Screen.Decal.Transparency = 1
        script.Parent.BrickColor = BrickColor.new("Crimson")
    end
end

script.Parent.ClickDetector.MouseClick:connect(function()
onClicked()
end)

see if this will work, not too sure myself

4 comments

0

oh and by the way this script will only work once or twice depending on what the default transparency is, if you need it to loop forever make sure to add the Decal.Transparency = 1 in the else statement.

0

That did the trick, it's been a while since I've started to script again. Thanks for the help.

0

could you please accept the answer then, thank you!

0

Sorry, I'm kinda new to this website.

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