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)