" attempt to index boolean with 'Value' " Error

I’m trying to check if my boolean value is set to true whenever a certain Bindable Event fires and gets received.The problem is that I keep getting this error whenever it checks it in the if statement:
image

Sections Of My Script (Placed In ServerScriptService):

-- Where I declare the boolValue
local raceInProgress = ServerStorage.RacingSystemStorage.RaceInProgress

BindableRaceEnd.Event:Connect(function(PlayerThatTouched, PlayerName)
	if raceInProgress.Value == true then -- Where the error happens

Any clue why this is happening, and how to fix it? Thanks for the help in advance.

1 Like

Are you setting to raceInProgress anywhere else in the script? This error doesn’t make sense given the context.

2 Likes

Yes, I use it throughout the (rather large) script. In the other parts of the script I change the value from false to true, etc. and there’s no error. So I find it strange why it would error here and not elsewhere.

What line does the error say the problem is located on?

If you change the variable to true/false, and not its .Value property, that’d cause the error. Make sure it’s always referring to the BoolValue and never a boolean. (e.g., ctrl+f for “raceInProgress =”)

8 Likes

Ahhh thanks very much! I found out that in another part of the script, I was setting the variable to true/false, so it must’ve caused the error like you said. Sigh… that was a dumb error by me haha

You have a good week! And thanks again.

2 Likes

Easy mistake to make, don’t worry about it. Good luck with your project.

2 Likes