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

Why isn't this script reading my BOOLEAN Value!?

Asked by 10 years ago
function clickd()
    if script.Parent.MusicENB == true then
    script.Parent.MusicENB = false
    J_ROOM.TextColor3 = Color3.new(170,0,0)
    else 
        script.Parent.MusicENB = true
        J_ROOM.TextColor3 = Color3.new(0,85,0)
    end
    end

script.Parent.MouseEnter:connect(hover)
script.Parent.MouseLeave:connect(unhover)
script.Parent.MouseButton1Click:connect(clickd)
J_ROOM = script.Parent
MOver = script.Parent.Parent.Parent.MOver

It is not working. It says that MusicENB is not a member of TextButton when it CLEARLY is and I do not know why. MusicENB is a BOOLEAN Value but for some reason it cannot be detected by the script!? Take a look at the img: http://i.imgur.com/OILBZ66.png

2 answers

Log in to vote
1
Answered by 10 years ago

That error has happened to me too sometimes when I tried to access a value. I learned that the problem was caused because I was trying to access the object itself, rather than it's property called Value, which actually stores the information. The correct way to have read the boolean would be like so:

function clickd()
    if script.Parent.MusicENB.Value == true then --I added a ".Value" to the end of "MusicENB" so that the script accesses its value rather than the object itself
        script.Parent.MusicENB.Value = false
        J_ROOM.TextColor3 = Color3.new(170,0,0)
    else 
        script.Parent.MusicENB.Value = true
        J_ROOM.TextColor3 = Color3.new(0,85,0)
    end
end

script.Parent.MouseEnter:connect(hover)
script.Parent.MouseLeave:connect(unhover)
script.Parent.MouseButton1Click:connect(clickd)
J_ROOM = script.Parent
MOver = script.Parent.Parent.Parent.MOver

Hope this helped!

Ad
Log in to vote
-1
Answered by
tambre2 25
10 years ago

You have to put your script in a local script.

Answer this question