Tweenservice making model do a 180

So I’m making a game, and I wrote a simple script that makes blast doors open and close on a specific timing. I want them to open/close one at a time, and everything here works good except that the model does a 180 while its going up, and stays backwards when coming back down. I’ve used tweens before, and I have no idea what’s wrong.

Video:

Script:

local door = script.Parent.Parent
local tween = game:GetService("TweenService")
local info = TweenInfo.new(5, Enum.EasingStyle.Quart, Enum.EasingDirection.In)
local open = tween:Create(door.Model.main, info, {CFrame = CFrame.new(door.Model.main.CFrame.X, door.Model.main.CFrame.Y + 21, door.Model.main.CFrame.Z)})
local close = tween:Create(door.Model.main, info, {CFrame = CFrame.new(door.Model.main.CFrame.X, door.Model.main.CFrame.Y, door.Model.main.CFrame.Z)})

while true do
	wait(0.1)
	if game.Workspace.bdtiming.Value == tonumber(script.Parent.Name) then
		if game.Workspace.bdclose.Value then
			close:Play()
		end
		if game.Workspace.bdclose.Value == false then
			open:Play()
		end
		game.Workspace.bdtiming.Value += 1
	end
end

Thanks!

1 Like

Tweening an entire CFrame? Just think easier and tween the main part position upwards so you don’t have to stress on these type of CfrAmE problems

you are not keeping the rotation property of the cframe when you are setting the goals

try this:

local door = script.Parent.Parent
local tween = game:GetService("TweenService")
local info = TweenInfo.new(5, Enum.EasingStyle.Quart, Enum.EasingDirection.In)
local open = tween:Create(door.Model.main, info, {CFrame = door.Model.Main.CFrame})
local close = tween:Create(door.Model.main, info, {CFrame = door.Model.main.CFrame + Vector3.new(0, 21, 0)})

while true do
	wait(0.1)
	if game.Workspace.bdtiming.Value == tonumber(script.Parent.Name) then
		if game.Workspace.bdclose.Value then
			close:Play()
		end
		if game.Workspace.bdclose.Value == false then
			open:Play()
		end
		game.Workspace.bdtiming.Value += 1
	end
end
local door = script.Parent.Parent.Model
local tween = game:GetService("TweenService")
local info = TweenInfo.new(5, Enum.EasingStyle.Quart)
local Open = tween:Create(door.main, info, {CFrame = door.main.CFrame + CFrame.new(0,21,0))
local Close = tween:Create(door.main, info, {CFrame = door.main.CFrame - CFrame.new(0,21,0))


while true do
	wait(0.1)
	if game.Workspace.bdtiming.Value == tonumber(script.Parent.Name) then
		if game.Workspace.bdclose.Value then
			Close:Play()
		end
		if game.Workspace.bdclose.Value == false then
			Open:Play()
		end
		game.Workspace.bdtiming.Value += 1
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.