Camera is stuck in the air when the CameraType is back to custom

I’m currently setting up the “pregame” of my round system, and I change the camera’s CFrame during this.

I’m having an issue when the CameraType is set back to custom, the camera goes way up in the air, and not focused around the player, and I think this warning connects to the issue. The CameraSubject is set to my humanoid, so it can’t be a problem with that property.

Here is the code that moves the camera:

--Set the camera's cframe to the map's view
print("setting type")
repeat
	camera.CameraType = Enum.CameraType.Scriptable
	wait(.1)
until camera.CameraType == Enum.CameraType.Scriptable
print("changing cframe")
camera.CFrame = mapViewCFrame

--Check the current status
if status.Value == "WaitingForPlayers" then
	--Waiting for players
	waitingText.Visible = true
	status.Changed:Wait()
	
	--Shrink the waiting text
	waitingText:TweenSize(UDim2.fromScale(0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, .4, true, function()
		waitingText.Visible = false
		waitingText:Destroy()
		wait(.2)
		teamSelection.Size = UDim2.fromScale(0, 0)
		teamSelection.Visible = true
		teamSelection:TweenSize(UDim2.fromScale(.345, .59), Enum.EasingDirection.Out, Enum.EasingStyle.Back, .5, true)
	end)
elseif status.Value == "SelectingTeams" then
	--Selecting teams
	teamSelection.Visible = true
end

--Wait for the status to change
if status.Value ~= "Preparing" then
	repeat
		status.Changed:Wait()
	until status.Value == "Preparing"
end

--Remove the team selection
teamSelection:TweenSize(UDim2.fromScale(0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, .5, true, function()
	teamSelection.Visible = false
	teamSelection:Destroy()
end)

--Readying cutscene
local function startingCutscene()
	print("playing start cutscene")
	--Get barriers
	local teamSpawns = workspace:WaitForChild("TeamSpawns")
	local teamBarrier
	local otherBarrier
	if not localPlayer.Team or localPlayer.Team.Name == "Guardians" then
		teamBarrier = teamSpawns:WaitForChild("GuardianSpawn"):WaitForChild("Barrier")
		otherBarrier = teamSpawns:WaitForChild("NightmareSpawn"):WaitForChild("Barrier")
		
	else
		teamBarrier = teamSpawns:WaitForChild("NightmareSpawn"):WaitForChild("Barrier")
		otherBarrier = teamSpawns:WaitForChild("GuardianSpawn"):WaitForChild("Barrier")
	end
	
	--Remove the team barrier
	teamBarrier.CanCollide = false
	teamBarrier.Transparency = 1
	otherBarrier.Transparency = 1
	
	--Get cframes
	local teamCframe1 = teamBarrier.CFrame:ToWorldSpace(CFrame.new(Vector3.new(-2, 0, -20), teamBarrier.Position + Vector3.new(2, 0, 0)))
	local teamCframe2 = teamCframe1:ToWorldSpace(CFrame.new(4, 0, 4))
	local otherCframe1 = otherBarrier.CFrame:ToWorldSpace(CFrame.new(Vector3.new(2, 0, -20), teamBarrier.Position + Vector3.new(-2, 0, 0)))
	local otherCframe2 = otherCframe1:ToWorldSpace(CFrame.new(-4, 0, 4))
	
	--Move the camera
	blur.Size = 0
	local camMoveInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
	camera.FieldOfView = 60
	camera.CFrame = teamCframe1
	local tween = tweenService:Create(camera, camMoveInfo, {CFrame = teamCframe2})
	tween:Play()
	tween.Completed:Wait()
	
	camera.CFrame = otherCframe1
	tween = tweenService:Create(camera, camMoveInfo, {CFrame = otherCframe2})
	tween:Play()
	tween.Completed:Wait()
	
	camera.CameraType = Enum.CameraType.Custom
	camera.FieldOfView = 70
	otherBarrier.Transparency = 0
end

--Play the cutscene
startingCutscene()
  1. What do you want to achieve? I want to make the camera move before a round begins.

  2. What is the issue? The camera correctly moves, but when it’s CameraType is custom again, it focuses in a position way up in the air.

  3. What solutions have you tried so far? I searched for similar posts, but I did not find a solution.

2 Likes

This might help:

They are also talking about it here:

After setting the CameraType to Custom, you must set the CameraSubject to the LocalPlayer’s humanoid. This could be done like this:

camera.CameraSubject = localPlayer.Humanoid

I have seen that first post, and didn’t find a solution, and thanks for linking the second post.

Updating the camera subject does not work. I checked, and the camera subject seems to still be set to the humanoid.

Edit: To clarify, I noticed that the warning is gone, but the camera is still stuck, so the warning has nothing to do with the issue then.

And you also set the CameraType back to Custom, right?

Yes. I actually fixed this issue and I have no idea how I fixed it, it just stopped happening out of the blue, so I guess my problem is solved.

1 Like