Why doesn't this set the camera to the player?

Try this:

if ending and not forcestop then
     if ending then
     camera.CameraType = Enum.CameraType.Custom
		local character = player.Character
		if character then
			camera.CameraType = Enum.CameraType.Custom --temp
			camera.CameraSubject = character
		end
	end
end

I have to go AFK again, but this time it’ll take max 8 minutes, sorry if i take a little bit more.

1 Like

Weird results. It goes from camera 1 to 2, and then glitches and moves back to camera 1, then PAST camera 1. Then, after a while, it teleports to camera 3 and the same issue reoccurs.

It also causes the player issue to happen again.
(player issue = click the button, but tween continues?)

Setting the code back also unfortunately caused the player issue to occur.

I’m gonna take a break, I’ll be back in about half an hour.

Hey dude, that’s a sad thing to hear.
Sorry that i couldn’t fix you’re problem yet…
Can you do team create? Maybe we can both fix this issue in studio.

Sorry, I can’t team create.

I just can’t believe such a simple issue with camera tweens ended up being like this. I’m going to go take another look at the code, see what I can change.

What does this line mean/do?

	tween.Completed:Wait()

It should wait until the tween is completed, then do the rest of the code.

Alright, let’s try and figure out the problem here.

I just removed

--[[if ending and forcestop == false then
			camera.CameraType = Enum.CameraType.Custom
			local character = player.Character
			if character then
				camera.CameraType = Enum.CameraType.Custom --temp
				camera.CameraSubject = character
			end
			]]--

I’m pretty sure it isn’t necessary as I’m looping it.

Try making so after the last function ends, it sets the camera type to Custom and the CameraSubject to the character

Change you’re code from this:

To this:

local TweenService = game:GetService("TweenService")
local cams = game.Workspace.Cameras
local done = false

local camera = game.Workspace.Camera

local sceneTime = 20

local tween = nil
local forcestop = false
local tweeninfo = TweenInfo.new(
	sceneTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	true,
	0
)

local player = game.Players.LocalPlayer

function TweenFunction(camera1, camera2, ending)
	if forcestop == false then
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CFrame = camera1.CFrame

		tween = TweenService:Create(camera, tweeninfo, {CFrame = camera2.CFrame})
		tween:Play()

		tween.Completed:Wait()
	end
end

script.Parent.MouseButton1Click:Connect(function()
	if tween then
		tween:Cancel()
		tween:Cancel()
		tween:Cancel()
		tween:Cancel()
		tween:Cancel()
	end
	camera.CameraType = Enum.CameraType.Custom
	local character = workspace:FindFirstChild(player.Name)
	if character then
		camera.CameraSubject = character
	end
	script.Parent.Parent.Parent.Enabled = false
	forcestop = true
end)

repeat
	if not forcestop then
		TweenFunction(cams.Camera1, cams.Camera2, false)
	end

	if not forcestop then
		TweenFunction(cams.Camera3, cams.Camera4, false)
	end

	if not forcestop then
		TweenFunction(cams.Camera5, cams.Camera6, false)
	end

	if not forcestop then
		TweenFunction(cams.Camera7, cams.Camera8, false)
	end

	if not forcestop then
		TweenFunction(cams.Camera9, cams.Camera10, true)
	end

    camera.CameraType = Enum.CameraType.Custom
	local character = player.Character
	if character then
		camera.CameraType = Enum.CameraType.Custom --temp
		camera.CameraSubject = character
	end

until forcestop

Try this code out.

1 Like

The tween still continues after the button is clicked, I just don’t understand how, and why.

Press the button and wait until the tween is over.
If the tween ends and nothing else happens, i think i have an idea to fix it.

I moved the forcestop = true to the top of the function, that seems to have fixed the issue of the camera still tweening after the button is clicked.

I see, is there any more other issue or is it completed?

Let me check if the camera still tweens to the player.

The issue still occurs, let me go over the code again. Thanks for all your help.

Which issue are you talking about? Also, no problem mate, glad i could help you.

Where it goes from camera 1 to 2, then goes to the player, then camera 3.

Ah geez, studio isn’t loading again.