Script does not acknowledge existence of a bool value

So I am trying to make a little button on GUI which will open or close door of the house but there’s a problem, the following script does not acknowledge existence of my boolValue even if I use WaitForChild

game.ReplicatedStorage.HouseDoorEvent.OnServerEvent:connect(function(player)
	if player.house.Value == 'house1' then
		if player.doorIsClosed.Value == false then
			game.Workspace.house1Rent.Parent = game.ServerStorage
			player:WaitForChild("doorIsClosed")
			player.doorIsClosed = true
		else
			game.ServerStorage.house1rent.Parent = game.Workspace
			player:WaitForChild("doorIsClosed")
			player.doorIsClosed = false
		end
	end
end)

The error is:
doorIsClosed is not a valid member of Player "Players.Lemon553311"

Thanks

Can you go in test mode and click on players and then click yourself, doorIsClosed is there or not?

Yup, its right here
image

so you can try adding :WaitForChild() and :FindFirstChild()

game.ReplicatedStorage.HouseDoorEvent.OnServerEvent:connect(function(player)
	if player:WaitForChild("house").Value == 'house1' then
		if player:WaitForChild("doorIsClosed").Value == false then
			game.Workspace.house1Rent.Parent = game.ServerStorage
			player:WaitForChild("doorIsClosed")
			player.doorIsClosed = true
		else
			game.ServerStorage.house1rent.Parent = game.Workspace
			player:WaitForChild("doorIsClosed")
			player.doorIsClosed = false
		end
	end
end)

are you creating the value in a localscript or serverscript

2 Likes

It is a server script

server script

Go into test mode, and click the server button and then check if the value is there

@Little_Joes Apparently I was a bit dumb and forgot to add .Value :no_mouth:
It actually must be

player.doorIsClosed.Value = true

I forgot that .Value exists

2 Likes

I’ve had this issue before too where I forgot to use .Value. I was about to tell you but you’ve already found it. Rip