I’m making a game, i’m coding a power box via cframe angles. But how can i make when the door closes, the position get back to normal?
Here’s an example of the bug i’m having:
The door’s orientation is closing correctly, but the position don’t.
How would i fix this bug?
My script:
local ProxPart = script.Parent
local Prox = ProxPart.ProximityPrompt
local TS = game:GetService("TweenService")
local Door = ProxPart.Parent.Door
local DoorCFrame = Door.CFrame
local Hinge = ProxPart.Parent.Hinge
local FixPowerGui = ProxPart.Parent.FixPowerGui
local TweenCFrame = Hinge.CFrame * CFrame.Angles(0, math.rad(120), 0)
local TweenCFrame2 = Hinge.CFrame * CFrame.Angles(0, 0, 0)
local DoorTween = TS:Create(Door, TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = TweenCFrame})
local DoorTween2 = TS:Create(Door, TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = TweenCFrame2})
local DB = false
local OpenSound = ProxPart.Open
Prox.Triggered:Connect(function(player)
if DB == false then
DoorTween:Play()
FixPowerGui.Enabled = true
OpenSound:Play()
FixPowerGui.FixPower.MouseButton1Up:Connect(function()
DoorTween2:Play()
DB = true
OpenSound:Play()
end)
end
end)
Any help would be appreciated