How can I fix this script so a door would open/close when I click on it?
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:
01 | local opener = script.Parent |
02 | local tween = game:GetService( "TweenService" ) |
04 | local pos = CFrame.new( 30.75 , 3 , 141.375 ) |
05 | local rot = CFrame.Angles( 0 , math.rad( 120 ), 0 ) |
07 | local tweenInfo = TweenInfo.new( |
09 | Enum.EasingStyle.Linear, |
10 | Enum.EasingDirection.Out, |
17 | opener.CFrame = = pos * rot |
20 | local tweenData = tween:Create(opener, tween, goals) |
22 | local function onMouseClick() |
23 | if opened = = false then |
28 | pos = CFrame.new( 28.75 , 3 , 139.875 ) |
29 | rot = CFrame.Angles( 0 , math.rad( 0 ), 0 ) |
34 | opener.ClickDetector.MouseClick:Connect(onMouseClick) |