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

Game wont recognnize boolean value?

My game doesnt recognize my boolean value, and whenever i run the game i get this error:

Players.SimplyBloo.PlayerGui.Menu.MenuMainScript:14: attempt to index local 'MenuOver' (a boolean value)

I have a boolean value in the Menu, where the script is located.

Here is my code:

local MenuOver = script.Parent:FindFirstChild("MenuOver")
MenuOver = false
print(MenuOver.Value)

What is the problem here?

3 comments

0

Uhm, where's the other part of the code?

0

Is the script inside the bool value and is this the full code?

0

just add ".Value" at the end, you're directing it to the instance when you just do "MenuOver"

3 answers

✓ Accepted answer

Explanation

The reason the output is printing attempt to index local 'MenuOver'( a boolean Value) is because that you have made a simple mistake in the script. You forgot to add the .Value after MenuOver because a BoolValue has a value inside it's properties called Value itself. You are trying toprint it's value when you haven't even set it's value, you have set it's boolean data type.

Problem

local MenuOver = script.Parent:FindFirstChild("MenuOver")
MenuOver = false
print(MenuOver.Value)

Adding a .Value after MenuOver would fix your problem.

Solution

local MenuOver = script.Parent:FindFirstChild("MenuOver") -- Define MenuOver

MenuOver.Value = false -- Set the value to false

print(MenuOver.Value) -- Print it's value to the output

Solution 2

local MenuOver = script.Parent:FindFirstChild("MenuOver") 

MenuOver = false

print(MenuOver)

Small tip

If you are ever trying to print something that has a value, just remember to add ``.Value` for example;

print(game.Workspace.Part.StringValue.Value)

I hope this helps you and please up vote this if it has fixed the issue..

It could be because you haven't set it yet, try changing MenuOver = false to MenuOver.Value = false

We're not really sure what happened there in your code but I think MenuOver is a Bool Value for your Menu Gui when it is over the screen.

local MenuOver = script.Parent:FindFirstChild("MenuOver")
MenuOver = false
print(MenuOver.Value)

This is the part where you replaced your MenuOver Bool Value with a Boolean data type false MenuOver = false

Doing this print(MenuOver.Value) would cause an error because it's a Data Type and it does not have any properties like Value.

EDIT: I forgot to add this xD

local MenuOver = script.Parent:FindFirstChild("MenuOver")
MenuOver.Value = false
print(MenuOver.Value)

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