How can I make 2 scripts completely synced?
I am working on a main menu system that contains multiple camera angles with each angle having different lighting effects(Depth of field, color correction, light rays). However, I am having issues with the timing of the scripts. Currently how it works is that the camera is not a local script, making every player share the same view on the main menu, every 10 seconds the camera teleports to a new location which is a different angle. I have timed it so the lighting script, which is a local script(so that players in-game won't be affected by the lighting) is almost exactly synced, (I used a remoteevent which fires causing the camera move script to work once the lighting starts). The problem that happens is that eventually, the lighting loses its sync with the camera movements, as well as when a player resets and is brought back to the menu it is entirely out of sync. I am looking for a solution to this issue but I am unsure how, I am not looking for code, just advice. Maybe if I change the placement of my scripts or if there is a way to combine them?
03 | local part = script.Parent |
04 | game.ReplicatedStorage.LightingStarts.OnServerEvent:Connect( function (player) |
06 | part.Position = Vector 3. new(- 1257.005 , - 47.561 , 781.581 ) |
07 | part.CFrame = CFrame.new(part.Position) * CFrame.Angles( 0 , math.rad(- 60 ), 0 ) |
08 | part.CFrame = part.CFrame * CFrame.Angles(math.rad( 15 ), 0 , 0 ) |
10 | part.Position = Vector 3. new(- 1461.755 , - 2.751 , - 733.411 ) |
11 | part.CFrame = CFrame.new(part.Position) * CFrame.Angles( 0 , math.rad( 15 ), 0 ) |
12 | part.CFrame = part.CFrame * CFrame.Angles(math.rad( 75 ), 0 , 0 ) |
14 | part.Position = Vector 3. new(- 1827.355 , 50.249 , - 5662.611 ) |
15 | part.CFrame = CFrame.new(part.Position) * CFrame.Angles( 0 , math.rad(- 60 ), 0 ) |
17 | part.Position = Vector 3. new(- 1339.683 , 42.476 , - 1993.297 ) |
18 | part.CFrame = CFrame.new(part.Position) * CFrame.Angles( 0 , math.rad( 120 ), 0 ) |
19 | part.CFrame = part.CFrame * CFrame.Angles(math.rad( 30 ), 0 , 0 ) |
If there is a way I can combine these scripts while keeping the lighting to only players on the main menu, that would be great.
03 | local DOF = game.Lighting.DepthOfField |
04 | local ColorCorrection = game.Lighting.ColorCorrection |
05 | local SunRays = game.Lighting.SunRays |
09 | game.ReplicatedStorage.LightingStarts:FireServer() |
12 | DOF.FarIntensity = 0.5 |
13 | DOF.FocusDistance = 12 |
14 | DOF.InFocusRadius = 10 |
16 | ColorCorrection.Contrast = 0.4 |
17 | ColorCorrection.Saturation = 0.5 |
18 | SunRays.Intensity = 0.3 |
21 | DOF.FocusDistance = 85 |
22 | DOF.InFocusRadius = 25 |
23 | DOF.NearIntensity = 0.5 |
24 | ColorCorrection.Contrast = 0.3 |
25 | ColorCorrection.Saturation = 0.2 |
26 | SunRays.Intensity = 0.7 |
28 | DOF.FarIntensity = 0.3 |
30 | DOF.InFocusRadius = 20 |
32 | ColorCorrection.Contrast = 0.2 |
33 | ColorCorrection.Saturation = 0.1 |
34 | SunRays.Intensity = 0.4 |
37 | DOF.FocusDistance = 500 |
40 | ColorCorrection.Contrast = - 0.1 |
41 | ColorCorrection.Saturation = 0.5 |
42 | SunRays.Intensity = 0.9 |