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

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

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

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!

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