How to break out of a cutscene when the player clicks "Play"?
Asked by
8 years ago Edited 8 years ago
So, I have a cutscene intro, with "Play" in front of it. When the player presses play, I want the camera to return to the player, and not continue the cutscene.
Part of script that is meant to move the camera to follow the player:
01 | script.Parent.Parent.Play.MouseButton 1 Click:connect( function () |
02 | local camera = workspace.CurrentCamera |
04 | camera.CameraType = Enum.CameraType.Attach |
05 | script.Parent.Visible = false |
06 | script.Parent.Parent.Play.Visible = false |
07 | workspace.CutscenePlayer:Destroy() |
10 | game.Lighting.Blur.Size = i |
17 | game.Lighting.Blue.Size = i |
Cutscene Script:
01 | repeat wait () until game.Workspace.CurrentCamera ~ = nil |
03 | local c = game.Workspace.CurrentCamera |
04 | local data = LoadLibrary( "RbxUtility" ).DecodeJSON(script.CutsceneData.Value) |
05 | local rs = game:GetService( "RunService" ).RenderStepped |
07 | function tweenCam(c 1 ,f 1 ,time,fov,roll) |
08 | local c 0 ,f 0 ,fv 0 ,r 0 ,frames = c.CoordinateFrame,c.Focus,c.FieldOfView,c:GetRoll(),time/ 0.015 |
10 | c.CameraType = "Scriptable" |
11 | c.CoordinateFrame = CFrame.new(c 0. p:lerp(c 1. p,i/frames),f 0. p:lerp(f 1. p,i/frames)) |
12 | c.FieldOfView = (fv 0 +(fov-fv 0 )*(i*( 1 /frames))) |
13 | c:SetRoll(r 0 +(roll-r 0 )*(i*( 1 /frames))) |
20 | c.CameraType = "Scriptable" |
21 | c.CoordinateFrame = CFrame.new( unpack (data [ 1 ] .c 1 )) |
22 | c.Focus = CFrame.new( unpack (data [ 1 ] .f 1 )) |
23 | c.FieldOfView = data [ 1 ] .FOV |
24 | c:SetRoll(data [ 1 ] .Roll) |
25 | if script:findFirstChild( "SkipCutsceneGuiValue" ) then |
26 | local gui = script.SkipCutsceneGui:clone() |
27 | gui.Parent = game.Players.LocalPlayer.PlayerGui |
28 | gui.Cutscene.Value = script |
29 | gui.Main.Debug.Disabled = false |
30 | script.SkipCutsceneGuiValue.Value = gui |
33 | tweenCam(CFrame.new( unpack (data [ i ] .c 1 )),CFrame.new( unpack (data [ i ] .f 1 )),data [ i ] .step,data [ i ] .FOV,data [ i ] .Roll) |
35 | c.CameraSubject = game.Players.LocalPlayer.Character.Humanoid |
36 | c.CameraType = "Custom" |
38 | if script:findFirstChild( "SkipCutsceneGuiValue" ) then |
39 | if script.SkipCutsceneGuiValue.Value ~ = nil then |
40 | script.SkipCutsceneGuiValue.Value:Destroy() |