So this script is supposed to play an animation in the main menu background but the camera position keeps setting back to the player and keeps making the spawn box visible , how can i fix this?
The code:
local TweenService = game:GetService("TweenService")
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = workspace.CameraPos.CFrame
local tween = TweenService:Create(
camera,
TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{
CFrame = CFrame.new(1449.324, 171.696, 732.863),
--Focus = CFrame.new(0, 0, 100)
}
)
tween:Play()
wait(2)
camera.CFrame = CFrame.new(832.325, 153.733, 250.701)
wait(0.2)
local tween2 = TweenService:Create(
camera,
TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{
CFrame = CFrame.new(832.325, 153.807, -711.536),
--Focus = CFrame.new(0, 0, 100)
}
)
tween2:Play()
Firstly, You’re not getting the player anywhere in here, so I don’t know what you mean by “to the player”. Secondly, and what may be the issue, is that when you create the first Tween, you set the time to 5, so when you wait 2 and then set the Camera.CFrame manually, your first tween is still running, so the tween immediately puts it back on track by sending it to the next position along the path, meaning that line did nothing. Then when your 2nd tween starts, the Camera is still somewhere along the 1st tweens path, and not at the point you attempted to set it to after your wait(2).
If you want to do this correctly, based on what you’re trying to do there are 2 ways:
-
if you want to stop the tween midway, then use Tween:Pause() after wait(2) and THEN set the camera CFrame.
-
If you want to set the Camera.CFrame after your first tween completes, use wait(5) instead of wait(2) or more optimally, use tween.Completed:Wait() instead of wait(2). This will cause the script to wait until the tween has fully completed before doing anything else.
I did the things that you wrote down, but now the cutscene starts from where the player spawns which is really not good, this happens when i give the tween.Completed:wait() a number to wait, but if i dont it finishes the first tween then sets back to the camera viewing the player and then starts the second tween from there. I hope this made sense.
Edit: now it broke entirely, without me editing the script at all