Why doesn't this music play immediatly?
01 | repeat wait () until game.Workspace.CurrentCamera ~ = nil |
02 | game.Workspace.Sound:Play( 143299986 ) |
04 | local c = game.Workspace.CurrentCamera |
05 | local data = LoadLibrary( "RbxUtility" ).DecodeJSON(script.CutsceneData.Value) |
06 | local rs = game:GetService( "RunService" ).RenderStepped |
08 | function tweenCam(c 1 ,f 1 ,time,fov,roll) |
09 | local c 0 ,f 0 ,fv 0 ,r 0 ,frames = c.CoordinateFrame,c.Focus,c.FieldOfView,c:GetRoll(),time/ 0.015 |
11 | c.CameraType = "Scriptable" |
12 | c.CoordinateFrame = CFrame.new(c 0. p:lerp(c 1. p,i/frames),f 0. p:lerp(f 1. p,i/frames)) |
13 | c.FieldOfView = (fv 0 +(fov-fv 0 )*(i*( 1 /frames))) |
14 | c:SetRoll(r 0 +(roll-r 0 )*(i*( 1 /frames))) |
21 | c.CameraType = "Scriptable" |
22 | c.CoordinateFrame = CFrame.new( unpack (data [ 1 ] .c 1 )) |
23 | c.Focus = CFrame.new( unpack (data [ 1 ] .f 1 )) |
24 | c.FieldOfView = data [ 1 ] .FOV |
25 | c:SetRoll(data [ 1 ] .Roll) |
26 | if script:findFirstChild( "SkipCutsceneGuiValue" ) then |
27 | local gui = script.SkipCutsceneGui:clone() |
28 | gui.Parent = game.Players.LocalPlayer.PlayerGui |
29 | gui.Cutscene.Value = script |
30 | gui.Main.Debug.Disabled = false |
31 | script.SkipCutsceneGuiValue.Value = gui |
34 | tweenCam(CFrame.new( unpack (data [ i ] .c 1 )),CFrame.new( unpack (data [ i ] .f 1 )),data [ i ] .step,data [ i ] .FOV,data [ i ] .Roll) |
36 | c.CameraSubject = game.Players.LocalPlayer.Character.Humanoid |
37 | c.CameraType = "Custom" |
39 | if script:findFirstChild( "SkipCutsceneGuiValue" ) then |
40 | if script.SkipCutsceneGuiValue.Value ~ = nil then |
41 | script.SkipCutsceneGuiValue.Value:Destroy() |
44 | game.Workspace.Sound:Stop( 143299986 ) |
Hey, I'm making a cutscene with sound, and when I put in this script (including cutscene script)
The music plays after like 20 seconds, almost when the cutscene is over.