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

Beginner here. Camera Manipulation doesn't work?

Asked by 6 years ago

I have a CameraPart as a camera, and a local script in StarterGui

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

function onCutscene()
    wait(19)
    repeat wait()
        Camera.CameraType = Enum.CameraType.Scriptable
    until Camera.CFrame == workspace.CameraPart.CFrame
    Camera.CFrame = workspace.CameraPart.CFrame
end

onCutscene()

And inside CameraPart, I have a script

CameraPart = script.Parent

function onCutscene()
    wait(19)
    for i = 1, 2000 do
        CameraPart.Position.Y = CameraPart.Position.Y + 0.2
        wait(0.01)
    end
end

onCutscene()

My intention is after 19 seconds, the camera's position will the CameraPart's position and it will go forward for 20 seconds, sort of like a cutscene. What are my errors and how can I correct them? Thanks in advance.

1 answer

Log in to vote
0
Answered by 6 years ago

The problem is in your first script, you made a mistake

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

function onCutscene()
    wait(19)
    repeat wait()
        Camera.CameraType = Enum.CameraType.Scriptable
    until Camera.CFrame == workspace.CameraPart.CFrame -- mistake here
    Camera.CFrame = workspace.CameraPart.CFrame
end

onCutscene()

should be

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

function onCutscene()
    wait(19)
    repeat wait()
        Camera.CameraType = Enum.CameraType.Scriptable
    until Camera.CameraType == Enum.CameraType.Scriptable
    Camera.CFrame = workspace.CameraPart.CFrame
end

onCutscene()

You should also use waitforchild

0
I think Scriptable makes the camera not move at all, it will just stay in one position. I corrected it and the camera didn't move, maybe I need to make the camera not scriptable and program it such that the player couldn't move the camera? EzraNewLight 6 — 6y
0
No, the camera would be moveble, just not for the player, I think your mistake is that you set the cframe so it won't folow the part, you should repeatly setting the CFrame until the animation is done User#20388 0 — 6y
0
I've corrected that by calling another function that makes the camera follow the part yet the part doesn't move. What is the error in the 2nd script? EzraNewLight 6 — 6y
0
Nvm, I put both 2nd and 1st script into one function, it worked. Thanks! EzraNewLight 6 — 6y
Ad

Answer this question