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

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
Elixcore 1337 Moderation Voter
6 years ago
Edited 6 years ago
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

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. Elixcore 1337 — 6y
0
That did the trick, it's been a while since I've started to script again. Thanks for the help. EarthDomination 4 — 6y
0
could you please accept the answer then, thank you! Elixcore 1337 — 6y
0
Sorry, I'm kinda new to this website. EarthDomination 4 — 6y
Ad

Answer this question