Ok, I was writing a Tween script where when you click on the door, it opens or closes depending on it's status. But the script is broken and I don't know what the problem is.
Here's the code:
local opener = script.Parent
local tween = game:GetService("TweenService")
local opened = false
local pos = CFrame.new(30.75, 3, 141.375)
local rot = CFrame.Angles(0, math.rad(120), 0)
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
1,
false,
0
)
local goals = {
opener.CFrame == pos * rot
}
local tweenData = tween:Create(opener, tween, goals)
local function onMouseClick()
if opened == false then
opened = true
tweenData:Play()
else
opened = false
pos = CFrame.new(28.75, 3, 139.875)
rot = CFrame.Angles(0, math.rad(0), 0)
tweenData:Play()
end
end
opener.ClickDetector.MouseClick:Connect(onMouseClick)
