Attribute Bool Value Not changing / stuck on false value

I have been stuck on this issue for days now, and it is frustrating me so much

I have recently began experimenting with attributes, first one being a boolvalue attribute.
My code is a simple door with a click detector that checks whether the attribute value is true or false, and opens or closes depending on the value. My issue is that the bool value is not changing to true at all, it just stays on false. I have tried everything , even GetAttributeChangedSignal , but nothing is working and it is really frustrating. This is my code, any help would greatly be appreciated


local Hinge = script.Parent.Hinge

local Door = script.Parent.Door

local IsOpen = script.Parent.Door:GetAttribute("IsOpen")
local DoorOpemSFX = script.Parent.Door.DoorOpenSFX
local Debounce = false

local ClickDetector = script.Parent.ClickDetector

local TweenService = game:GetService("TweenService")

local DoorInfo = TweenInfo.new(
	.8,
	Enum.EasingStyle.Circular,
	Enum.EasingDirection.Out,
	0,
	false
)


local DoorOpen = {}
DoorOpen.CFrame = Hinge.CFrame * CFrame.Angles(0 , math.rad(110) , 0)

local DoorClose = {}
DoorClose.CFrame = Hinge.CFrame * CFrame.Angles(0 , math.rad(0) , 0)

local OpenDoor = TweenService:Create(Hinge , DoorInfo , DoorOpen)
local CloseDoor = TweenService:Create(Hinge , DoorInfo , DoorClose)

local function OpenDoorFunction()
		
	OpenDoor:Play()
	DoorOpemSFX:Play()
	
end

local function CloseDoorFunction()
	
	CloseDoor:Play()
	
end


ClickDetector.MouseClick:Connect(function()
	
	if IsOpen == false and Debounce == false then
		Debounce = true
		
		OpenDoorFunction()
		
		Door:GetAttributeChangedSignal("IsOpen"):Connect(function()
			
			Door:SetAttribute("IsOpen" , true)
			
		end)
		
		print(IsOpen)
		
		task.wait(1)
		Debounce = false
		
	elseif IsOpen == true and Debounce == false then
		Debounce = true
		
		CloseDoorFunction()
		
		Door:GetAttributeChangedSignal("IsOpen"):Connect(function()

			Door:SetAttribute("IsOpen" , false)

		end)
		
		print(IsOpen)

		task.wait(1)
		Debounce = false
		
	else
		
		print("Debounce On.")
		
	end
	
	
end)




Just saying, but I think GetAttribute returns a value, not an Attribute. If you want to modify attributes you have to directly set the instance’s attribute using Instance:SetAttribute.

It’s like doing local Value = script.Parent.BoolValue.Value, this only returns the BoolValue's value, not the BoolValue itself.

I am using SetAttribute, its in the attribute changed functions, but even when i use them without an attributechangedsignal function, the value still does not change from false to true

Edit: I have tested yet again without the getpropertychangedsignal functions and the value still is stuck on false

Edit 2: after some tweaking I found a solution , I did not need to get the attribute every time since earlier in the script i had already gotten the attribute , i just had to set it equal to true and false

2 Likes