Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I fix a broken camera after a cutscene?

Asked by 4 years ago

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?

0
you can make the camera target the local player's humanoid Igoralexeymarengobr 365 — 4y
0
would that work? I mean, when the character gets re-generated, isn't there a new camera that gets generated too? RiskoZoSlovenska 378 — 4y

1 answer

Log in to vote
1
Answered by
Fifkee 2017 Community Moderator Moderation Voter
4 years ago

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

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. Fifkee 2017 — 4y
Ad

Answer this question