local PivotPoint = CFrame.new(script.Parent.Position)
local Part = script.Parent
local OpenValue = script.Parent.Parent.Parent:WaitForChild("Open")
OpenValue.Value = false
local AngleRotation = 1
local WorldPartCFrame = PivotPoint * CFrame.Angles(0, math.rad(AngleRotation), 0)
local ObjectPartCFrame = WorldPartCFrame:ToObjectSpace(Part.CFrame)
local function Close()
WorldPartCFrame = WorldPartCFrame * CFrame.Angles(0, math.rad(1), 0)
Part.CFrame = WorldPartCFrame * ObjectPartCFrame
end
local function Open()
WorldPartCFrame = WorldPartCFrame * CFrame.Angles(0, math.rad(-AngleRotation), 0)
Part.CFrame = WorldPartCFrame * ObjectPartCFrame
end
local MoveTask
local MoveDebounce = false
local function Move()
if OpenValue.Value == true then
MoveDebounce = true
repeat
Close()
task.wait()
until Part.Orientation.Z >= 90
Part.CFrame = CFrame.Angles(0, math.rad(90), 0)
MoveDebounce = false
elseif OpenValue.Value == false then
MoveDebounce = true
repeat
Open()
task.wait()
until Part.Orientation.Z >= -90
Part.CFrame = CFrame.Angles(0, math.rad(-90), 0)
MoveDebounce = false
end
end
OpenValue:GetPropertyChangedSignal("Value"):Connect(function()
if MoveDebounce == true then
task.cancel(MoveTask)
MoveTask = task.spawn(Move)
elseif MoveDebounce == false then
MoveTask = task.spawn(Move)
end
end)
When the open Value is changed, the part will rotate. The rotation is perfect fine , HOWEVER, i only want it to rotate for 90 degrees, hyowever, I do not know how to check when the Z axis will = 90, and above.
For those who do not know what i am talking about, i placed this in my script so you can know abit of what im talking about. I know its wrong but it should give sense on what im talking about
until Part.Orientation.Z >= -90