script:
local tweenservice = game.TweenService local right = game.Workspace.carshopdoors.carshoprightdoor local left = game.Workspace.carshopdoors.carshopleftdoor local tweenstyle = TweenInfo.new( 1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0 ) local leftdoorclose = { CFrame = CFrame.new(-187.32, 6.1, -1216.665), Rotation = Vector3.new(0, 20, 0) } local rightdoorclose = { CFrame = CFrame.new(-184.71, 6.1, -1209.494), Rotation = Vector3.new(0, 20, 0) } local leftdooropen = { CFrame = CFrame.new(-184.764, 6.1, -1221.919), Orientation = Vector3.new(0, -70, 0) } local rightdooropen = { CFrame = CFrame.new(-179.131, 6.1, -1206.973), Orientation = Vector3.new(0, -70, 0) } local leftclose = tweenservice:Create(left,tweenstyle,leftdoorclose) local rightclose = tweenservice:Create(right,tweenstyle,rightdoorclose) local leftopen = tweenservice:Create(left,tweenstyle,leftdooropen) local rightopen = tweenservice:Create(right,tweenstyle,rightdooropen) local active = true script.Parent.Touched:Connect(function() if active then active = false print("working") leftopen:Play() rightopen:Play() wait(2) active = true end end)
sometimes it goes like this https://imgur.com/a/dCggpAZ
other times it goes like this https://imgur.com/a/iFDhsuG
how can i make it always work as https://imgur.com/a/iFDhsuG
EDIT: Math error
CFrames are complete coordinate frame of an object in the game, so they set orientation too, every time you use CFrame.new. That means you do not really need to tween orientation as well. Also that is probably why you have issues with your doors. I will amend your script to use CFrame only. I assume that the door wings are closed at the start of the game.
local tweenservice = game.TweenService local right = game.Workspace.carshopdoors.carshoprightdoor local left = game.Workspace.carshopdoors.carshopleftdoor local tweenstyle = TweenInfo.new( 1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0 ) local leftdoorclose = { CFrame = left.CFrame --just remember starting position. } local rightdoorclose = { CFrame = right.CFrame } local leftdooropen = { CFrame = (left.CFrame + Vector3.new(2.556,0,-5.254)) * CFrame.Angles(0,math.rad(90),0) -- it is beter to use relative values, so you can make easy copies if you need to } local rightdooropen = { CFrame = (right.CFrame + Vector3.new(5.579,0,2.521)) * CFrame.Angles(0,math.rad(-90),0) } local leftclose = tweenservice:Create(left,tweenstyle,leftdoorclose) local rightclose = tweenservice:Create(right,tweenstyle,rightdoorclose) local leftopen = tweenservice:Create(left,tweenstyle,leftdooropen) local rightopen = tweenservice:Create(right,tweenstyle,rightdooropen) local active = true script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("HumanoidRootPart") then --add a humanoid check to prevent door self activating. if active then active = false print("working") leftopen:Play() rightopen:Play() wait(2) active = true end end end)
Have a nice scripting session.