Camera shifting problem

Hey there! I always want to give my players the best quality.

As a main menu for my upcoming game, GRIEF, and i wanted the camera to switch to different scenes, to attract players. However, after testing the menu out on my phone, i have encountered a problem. Sometimes, the cameras do not go their designated destination i set (probably because of lag) and make the game look unprofessional.

An example is Camera 6 going to Camera 2 with the Animation

Here is the local script:

local camera = workspace.CurrentCamera

local Camera1 = workspace:WaitForChild(“Camera1”)

local Camera2 = workspace:WaitForChild(“Camera2”)

local Camera3 = workspace:WaitForChild(“Camera3”)

local Camera4 = workspace:WaitForChild(“Camera4”)

local Camera5 = workspace:WaitForChild(“Camera5”)

local Camera6 = workspace:WaitForChild(“Camera6”)

local TweenService = game:GetService(“TweenService”)

local TweenInformation = TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

repeat wait()

camera.CameraType = Enum.CameraType.Scriptable

until camera.CameraType == Enum.CameraType.Scriptable

local goal1 = {CFrame = Camera2.CFrame}

local Animation1 = TweenService:Create(camera,TweenInformation,goal1)

local goal2 = {CFrame = Camera4.CFrame}

local Animation2 = TweenService:Create(camera,TweenInformation,goal2)

local goal3 = {CFrame = Camera6.CFrame}

local Animation3 = TweenService:Create(camera,TweenInformation,goal3)

while true do

camera.CFrame = Camera1.CFrame

wait()

Animation1:Play()

wait(4.03)

camera.CFrame = Camera5.CFrame

Animation3:Play()

wait(4.03)

end

If you would like a video (of how the menu looks without the problem) please let me know.

Any help would be much appreciated! :grin:

Why don’t you wait till the tween is finished instead of wait(4.03)?

1 Like

I have recategorised this from Code Review to Scripting Support. Please read our category guidelines and/or summaries to check if you are posting in the right category. Code Review is for improving already working code, while Scripting Support is for other help questions.

1 Like

The wait(4.03) is to make sure the script has 0.03 seconds in advance to get ready for the next line of code. Also, if i don’t put the wait it will go straight to the next line of code which will mess up the whole camera system in general.

Hope this helps! :+1:

Sorry it’s my second day here. Ill make sure to get the correct category for my queries next time. :+1:

I meant like doing like tweenName.Completed:Wait() so it waits for the tween to be completed instead of writing wait(4.03)

1 Like

Sorry for the late reply. It fixed it! I have no idea how to thank you enough!

Take care :+1:

1 Like