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

why wont Camera revert to players head?

Asked by
TickoGrey 116
3 years ago

ok so I was working on a cutscene and the localscript that handles the camera position works mostly fine but whenever the cutscene ends the camera will freeze and not go back to the player

btw the script is named CameraScript because for some reason it won't work any other way'

local cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
a = false
b = 0
while a == false do
    if game.Workspace.camveiw1 then
        cam.CFrame = game.Workspace.camveiw1.CFrame
        wait()
        b = b+1
        print(b)
        if b == 250 or not game.Workspace.camveiw1 then
            a = true
        end     
    end
end
cam.CameraType = Enum.CameraType.Custom
char = game.Players.LocalPlayer.Character
if char then
    print("gaming")
    cam.CameraSubject = char.Head
end

it counts to 200, prints "gaming" then it just freezes the camera (and the brick the camera is following flys away)

1 answer

Log in to vote
0
Answered by 3 years ago

Your script isn't in the correct order. You are making sure the player's camera isn't scriptable and then trying to script it. To fix: just rearrange to this:

char = game.Players.LocalPlayer.Character
if char then
    print("gaming")
    cam.CameraSubject = char.Head
end
cam.CameraType = Enum.CameraType.Custom

I hope this answers your question

0
this does not work TickoGrey 116 — 3y
Ad

Answer this question