Issue with reading from BoolValue

Ok so I’m trying to check a BoolValue to see if the player is holding a weapon or not, and I keep getting the error

ReplicatedStorage.Modules.MainModule:191: attempt to index boolean with 'Value'

It’s a function that runs on Heartbeat, and I’ve checked it to make sure I’m reading from the Value property of the instance. I’ve tried a couple of things, such as writing to it from the server at the beginning of the script, and using :WaitForChild() to declare it as a variable, but nothing has worked. I’ve poured over about 10 DevForum threads for this. To clarify, this only happens when I’m reading from a BoolValue in an if statement. The function is being called from a LocalScript. Any help is appreciated!

Edit: BTW I’m about to go on an 8 hour flight so I won’t respond immediately.

Function:

function Module.SetPlayerStatus()
	--Civilian status
	--if PlayerZone.Value == 0 and PlayerOutfit.Value == 0 and PlayerArmed.Value == false then
		PlayerStatus.Value = 0
	--end
	--Disguised status
	if ReplicatedStorage.PlayerOutfit.Value == 1 then
		PlayerStatus.Value = 6
	end
	--Conspicious status
	if PlayerOutfit.Value == 1 and PlayerArmed.Value == true then
		PlayerStatus.Value = 7
	end
	--White trespassing
	if PlayerOutfit.Value == 0 and PlayerZone.Value == 1 then
		PlayerStatus.Value = 2
	end
	--Red trespassing
	if PlayerOutfit.Value == 0 and PlayerZone.Value == 2 then
		PlayerStatus.Value = 3
	end
	--Suspicious status
	if PlayerSuspicious.Value == true then
		PlayerStatus.Value = 4
	end
	--Armed status
	if PlayerOutfit.Value == 0 and PlayerArmed.Value == true then
		PlayerStatus.Value = 1	
	end
	--Intimidating status
	--nothing
end

How I’m declaring the objects:

local PlayerArmed = ReplicatedStorage:WaitForChild("PlayerArmed")
local PlayerStatus = ReplicatedStorage.PlayerStatus
local PlayerOutfit = ReplicatedStorage.PlayerOutfit
local PlayerZone = ReplicatedStorage.PlayerZone
local PlayerSuspicious = ReplicatedStorage.PlayerSuspicious

There’s another function of Module that accidently sets one of your value variables, I assume either PlayerArmed or PlayerSuspicious to a bool value directly instead of setting their .Value property.

To search for that you can open your Module, press Ctrl+F and in the textbox that appears search for PlayerArmed = true, PlayerArmed = false, PlayerSuspicious = true and PlayerSuspicious = false. If you find any of those add a .Value next to them.

In general it’s not a good idea to use global variables because a function messing up can cause issues to another.

Yep, that was it. I don’t know how I didn’t think to use Ctrl+F, but thanks for the help. I feel kinda dumb now lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.