Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I fix a broken camera after a cutscene?

So I have this game, where when a round ends, the players are teleported to the lobby via player:LoadCharacter (I load their character instead of TPing them because the only spawns in the game are in the lobby, and this also neatly removes SpotLights, Tools and similar objects from the player). However, before they get "teleported", I want each player to see a "cutscene"/cinematic, which consists of their camera moving to look at a certain object. How I do this is that I have an event, which is fire to all player client who participated in the match, from a ServerScript. In a LocalScript under the player, it receives this event, and does this:

--cinematicSpeed = 5
local function doCinematic()
	print("Cinematic request")
	clientSounds.EndBells:Play()
	local camera = game.Workspace.CurrentCamera
	camera.CameraType = Enum.CameraType.Scriptable
	local tweenInfo = TweenInfo.new(cinematicSpeed)
	local movePosition = CFrame.new(2388.22705, 172.639359, -801.751831, -0.91318661, 0.174258858, 0.368407518, -1.49011612e-08, 0.90397495, -0.427585363, -0.407541722, -0.39046523, -0.825497806)
	local tween = TweenService:Create(camera, tweenInfo, {CFrame = movePosition})
	tween.Parent = camera
	tween:Play()
	tween.Completed:Wait()
	camera.CameraType = Enum.CameraType.Custom
	tween:Destroy()
end

The Script that fires the event fires the even for a player, than waits two seconds, and then "teleports" the player. The problem is, after the cutscene plays, the camera snaps back to where it was before the cutscene began, which is usually above the battlefield, and stays there indefinitely.

How can I fix this? Is it simply a question of not setting the camera type to Scriptable? Or will just Destroy()ing the old camera generate a new one and fix it? Or is it un-fixable, and I just have to reset the players and THEN call the cutscene?

2 comments

0

you can make the camera target the local player's humanoid

0

would that work? I mean, when the character gets re-generated, isn't there a new camera that gets generated too?

1 answer

✓ Accepted answer

Delete the camera. That's all there is to it. :P

1 comment

0

For further information: When the CurrentCamera is deleted, it instantly gets remade. Though, your camera's zoom distance will be reset too, so that might be a bit tedious to the players.

This discussion is preserved as it was. New answers, comments, and votes are closed.