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

How do I play sound for only the guy in the cutscene?

Asked by 9 years ago

Hey, I have a cutscene with music, but if someone joins, you hear the music. It's ugly. How do I make it only for the guy who's ment to? Cutscene script:

repeat wait () until game.Workspace.CurrentCamera ~= nil
game.Workspace.Sound:Play(148206769)

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
game.Workspace.Sound:Stop(148206769)
script:Destroy()

I'd also like to know when I have a skip button, how to let the music stop when the skip button is pushed?

1 answer

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

The Cutscene script:

repeat wait () until game.Workspace.CurrentCamera ~= nil
Sound=game.Workspace.Sound
SoundC=Sound:clone()
SoundC.Parent=game.Players.LocalPlayer.PlayerGui
SoundC:Play()

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
SoundC:remove()
script:Destroy()

The "Main" script:

repeat wait () until script.Parent.Cutscene.Value ~= nil
script.Parent.Skip.Visible = true

function onClicked()
    script.Parent.Cutscene.Value:Destroy()
    game.Workspace.CurrentCamera.CameraType = "Custom"
    game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
    game.Workspace.CurrentCamera.FieldOfView = 70
    script.Parent:Destroy()
    game.Players.LocalPlayer.PlayerGui.Sound:remove()
end

script.Parent.Skip.MouseButton1Down:connect(onClicked)

This should all work now...I tested it and it worked for me so...

0
Now the whole cutscene wont start up. Maybe I have to put the first 8 sentences after number 10? coolguy1v1 0 — 9y
0
Oh, sorry about that. I think you're right. Try that, if it doesnt work, let me know dyler3 1510 — 9y
0
It does not. I saw if I do the thing you did, that the second person who joins get the cutscene, but yet no sound. also, the skip button dissapears. coolguy1v1 0 — 9y
0
Maybe I could send you the script via email, or something, so you could make it work? (or the whole game, so you can let it fit) coolguy1v1 0 — 9y
View all comments (4 more)
0
I will send you a roblox PM coolguy1v1 0 — 9y
0
I sent you a pm. coolguy1v1 0 — 9y
0
Ok, we'll talk on their dyler3 1510 — 9y
0
When will we talk??? coolguy1v1 0 — 9y
Ad

Answer this question