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

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:

script.Parent.Parent.Play.MouseButton1Click:connect(function()
    local camera = workspace.CurrentCamera

    camera.CameraType = Enum.CameraType.Attach
    script.Parent.Visible = false
    script.Parent.Parent.Play.Visible = false
    workspace.CutscenePlayer:Destroy()

    for i = 0, 24, 1 do
        game.Lighting.Blur.Size = i 
        wait(0.09)
    end

    wait(3)

    for i = 24, 0, 1 do
        game.Lighting.Blue.Size = i
        wait(0.09)
    end
end)

Cutscene Script:

repeat wait () until game.Workspace.CurrentCamera ~= nil

local c = game.Workspace.CurrentCamera
local data = LoadLibrary("RbxUtility").DecodeJSON(script.CutsceneData.Value)
local rs = game:GetService("RunService").RenderStepped

function tweenCam(c1,f1,time,fov,roll)
    local c0,f0,fv0,r0,frames = c.CoordinateFrame,c.Focus,c.FieldOfView,c:GetRoll(),time/0.015
    for i = 1,frames do
        c.CameraType = "Scriptable"
        c.CoordinateFrame = CFrame.new(c0.p:lerp(c1.p,i/frames),f0.p:lerp(f1.p,i/frames))
        c.FieldOfView = (fv0+(fov-fv0)*(i*(1/frames)))
        c:SetRoll(r0+(roll-r0)*(i*(1/frames)))
        rs:wait()
    end
end

print("Running")
c.CameraSubject = nil   
c.CameraType = "Scriptable"
c.CoordinateFrame = CFrame.new(unpack(data[1].c1))
c.Focus = CFrame.new(unpack(data[1].f1))
c.FieldOfView = data[1].FOV
c:SetRoll(data[1].Roll)
if script:findFirstChild("SkipCutsceneGuiValue") then
    local gui = script.SkipCutsceneGui:clone()
    gui.Parent = game.Players.LocalPlayer.PlayerGui
    gui.Cutscene.Value = script
    gui.Main.Debug.Disabled = false
    script.SkipCutsceneGuiValue.Value = gui
end
for i = 2,#data do
    tweenCam(CFrame.new(unpack(data[i].c1)),CFrame.new(unpack(data[i].f1)),data[i].step,data[i].FOV,data[i].Roll)
end
c.CameraSubject = game.Players.LocalPlayer.Character.Humanoid   
c.CameraType = "Custom"
c.FieldOfView = 70
if script:findFirstChild("SkipCutsceneGuiValue") then
    if script.SkipCutsceneGuiValue.Value ~= nil then
        script.SkipCutsceneGuiValue.Value:Destroy()
    end
end
script:Destroy()

1 answer

Log in to vote
0
Answered by 8 years ago

Well, Im not sure about making a "play button" but if you configure the script, there is a button which says skip cutscene. I will look into thsi later on

0
Or You could do a button which basically destroys the cutscene tonyv537 95 — 8y
Ad

Answer this question