https://gyazo.com/8785e05347b36fc1d0fc03e25ae4eb80 im trying to tween a model but for some reason it glitches when closing
01 | local openDoor = script.Parent.Parent.Parent.DoorOpen |
02 | local closeDoor = script.Parent.Parent.Parent.DoorClose |
03 | local move = script.Parent.Parent.Move |
04 |
05 | local open = script.Parent.Parent.Open.Value |
06 |
07 | local clickdetector = script.Parent.ClickDetector |
08 |
09 | local tweenservice = game:GetService( "TweenService" ) |
10 | local tweeninfo = TweenInfo.new( |
11 | 0.5 , |
12 | Enum.EasingStyle.Quad, |
13 | Enum.EasingDirection.InOut, |
14 | 0 , |
15 | false , |
The problem is that your using 2 if statements. The alternative is to combine them.
01 | clickdetector.MouseClick:Connect( function (plr) |
02 |
03 | if not open then |
04 |
05 | open = true |
06 |
07 | tweenModel(script.Parent.Parent,openDoor:GetPrimaryPartCFrame()) |
08 |
09 | elseif open then |
10 |
11 | open = false |
12 | tweenModel(script.Parent.Parent,closeDoor:GetPrimaryPartCFrame()) |
13 |
14 | end |
15 |
16 | end ) |
The reason it's glitchy was because after the first if-statement, the second if-statement ran.