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

Camera is not going back to players control original view after tweening?

Asked by 3 years ago
Edited 3 years ago
--All scripts made by BM
local TweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
flag = true
local cam = game.Workspace.Camera 
local cutsceneTime = 8
local tweenInfo = TweenInfo.new(
    cutsceneTime,
    Enum.EasingStyle.Quad,
    Enum.EasingDirection.Out,
    0,
    false, 
    0
)

function tween(part1, part2)
    while flag do
        wait(.1)
        cam.CameraType = Enum.CameraType.Scriptable
        cam.CFrame = part1.CFrame  
        local tween = TweenService:Create(cam, tweenInfo, {CFrame = part2.CFrame})
        tween:Pause()
        script.Parent.MouseButton1Click:Connect(function()
            tween:Play()
            flag = false    
        end)
    end
end

wait(.1)
--Wait til player presses play
tween(workspace.cam1, workspace.cam2)
if flag == false then
    camToPlayer()
end

function camToPlayer()
    wait(cutsceneTime)
    cam.CameraType = Enum.CameraType.Scriptable
    player.CameraMode = Enum.CameraMode.Classic --This part doesn't work idk why
end

-I tried different variations such as cam.CameraType = Enum.CameraType.Custom in the function camToPlayer and it just won't reset to player cam control after camera tweening it just stays stationary in my workspace.cam2. Help?

0
Format your code please. radiant_Light203 1166 — 3y
0
Formatted now. TruGalaxy 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

The easiest way to reset the camera is:

camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = humanoid -- path to the player's character's humanoid

Try changing your script:

-- lines ~23
tween:Play()
tween.Completed:Wait()
flag = false
0
Unfortunately does not work. TruGalaxy 0 — 3y
0
If I'm reading the code properly; you don't wait for the player to press the button so he can change flag to false. You tween the camera, check if flag is false - but since it isn't, the camera won't pan back. Let me edit my answer. radiant_Light203 1166 — 3y
0
No luck I guess. The Wait() command also doesn't fire the tween:Play(). with Connect() it works and fires the tweening event but after that, it gets stuck in camera position part 2 and I can not seem to get it to go back to the players camera. TruGalaxy 0 — 3y
0
Well, third time's the charm. How about now? radiant_Light203 1166 — 3y
View all comments (2 more)
0
All it fails to do is return to the players camera view. Everything else works fine. TruGalaxy 0 — 3y
0
Can you verify by a print statement, to see if the relevant lines, e.g in the if condition and in the function camToPlayer() are running? radiant_Light203 1166 — 3y
Ad

Answer this question