Hey I've had a little trouble with this code and my limited knowledge of lua is really starting to show hehe. Anyway the code doesn't fire even when the conditions are met (both Booleans where triggered through their own code and also manually while testing)
The code receives no errors and works perfectly when not inside the if statement however as soon as you put it into an if statement it decides that nope it doesnt want to work.
local door = workspace.DoorEntrance
local TweenService = game:GetService("TweenService")
local doorstatus = door.DoorStatus
local powerstatus = script.Parent.Parent.Parent.PowerControls.PanelOnePower
local openlight = script.Parent.OpenLight
local closelight = script.Parent.Parent.GateClose.CloseLight
local testlight = script.Parent.TestLight
local sound = door.Sound
local hinge1 = door.Door1.PrimaryPart
local hinge2 = door.Door2.PrimaryPart
local door1open = TweenInfo.new(15)
local door2open = TweenInfo.new(15)
-------------------------------------
local doorCFrame1 = TweenService:Create(hinge1, door1open, {
CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(80),0)
})
local doorCFrame2 = TweenService:Create(hinge2, door2open, {
CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(-80),0)
})
-------------------------------------
function open()
--sound:Play()
doorCFrame1:Play()
doorCFrame2:Play()
task.wait(15)
openlight.Color = Color3.fromRGB(2, 107, 91)
closelight.Color = Color3.fromRGB(69, 71, 80)
doorstatus = true
end
-------------------------------------
function onClicked()
print("Click Registered")
--open()
print(doorstatus,powerstatus)
if doorstatus == false and powerstatus == true then
open()
print("Door Opening Function Called")
end
script.Parent.Button.ClickDetector.MouseClick:connect(onClicked)