The positions are in the right places, I have the door tween to the Pos part, which changes position to ClosedPosition when the door is done is opening, then if I click on the door again it should tween to the Pos's position and orientation again, which should have changed position to the closed door, but it still doesn't do it, I made it print something at the end of both ifs and it worked. I'm just very confused at the moment

local tweenService = game:GetService("TweenService")
local part = script.Parent

local tweeningInformation = TweenInfo.new(
	
1.5, --Length
Enum.EasingStyle.Cubic, --Easing Style
Enum.EasingDirection.Out, --Easing Direction
0, --Repeats
false, --backtrack
0 --tween delay
	)
----------------
local partProperties = {
Position = script.Parent.Parent.Pos.Position,
Orientation = script.Parent.Parent.Pos.Orientation

	
	
}
local Tween = tweenService:Create(part,tweeningInformation,partProperties)

----

function onClicked(playerWhoClicked)
		if script.Parent.Parent.State.Value == 1 then
			script.Parent.Parent.State.Value = 2
			script.Parent.ClickDetector.MaxActivationDistance = 0
			Tween:Play()
			script.Parent.Open:Play()
			wait(1.5)
			script.Parent.Parent.Pos.Position = script.Parent.Parent.ClosedPosition.Position
			script.Parent.Parent.Pos.Orientation = script.Parent.Parent.ClosedPosition.Orientation
			script.Parent.ClickDetector.MaxActivationDistance = 5
			
	elseif script.Parent.Parent.State.Value == 2 then
			script.Parent.Parent.State.Value = 1
			script.Parent.ClickDetector.MaxActivationDistance = 0
			Tween:Play()
			script.Parent.Close:Play()
			wait(1.5)
			script.Parent.Parent.Pos.Position = script.Parent.Parent.OpenPosition.Position
			script.Parent.Parent.Pos.Orientation = script.Parent.Parent.OpenPosition.Orientation
			script.Parent.ClickDetector.MaxActivationDistance = 5
	end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

4 comments

0

Hm, What a weid way to use cooldowns.

0

I'm not a great scripter and am doing it the only way I know how, though this time it's not working, this is also my first time using tweenService

0

Try using a loop

0

nope, didn't work