Cutscene breaks half the time

I’m trying to make my cutscene play a transition when it ends, and it teleports the player to a part which changes their team in workspace.


the problem is that half the time, it breaks, and the transition doesn’t tween.

local TweenService = game:GetService("TweenService")
local player = game:GetService("Players")
local localplayer = player.LocalPlayer
local destination = workspace:WaitForChild("SpawnPoint")
local humanoid = localplayer.Character
local leftcenterright = script.Parent.Parent.Transition.Frame
local camera = game.Workspace.CurrentCamera
local cutsceneTime = 3
local tweenInfo = TweenInfo.new(
	cutsceneTime,
	Enum.EasingStyle.Cubic,
	Enum.EasingDirection.InOut,
	0,
	false,
	0
)

function tween(cam1,cam2)
	print('FLORP GLORP!!!')
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = cam1.CFrame
	
	local tween = TweenService:Create(camera, tweenInfo, {CFrame = cam2.CFrame})
	tween:Play()
	tween.Completed:Connect(function()
		leftcenterright.Visible = true
		leftcenterright.Position = UDim2.new(-1,0,0,0)
		humanoid.HumanoidRootPart.CFrame = destination.CFrame + Vector3.new(0,3,0)

		leftcenterright:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad,1,false, nil)
		print('FLUTT GLUT')
		wait(1)
		camera.CameraType = Enum.CameraType.Custom
		leftcenterright:TweenPosition(UDim2.new(1,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,false, nil)
		print("DESTROY YOU!")
		wait(1)
		leftcenterright.Visible = false

	end)
end

wait(1)

tween(game.Workspace.Cam1,game.Workspace.Cam2)
task.wait(4)
script:Destroy()

BTW its a local script inside of a screengui in startergui

1 Like