Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Beginner here. Camera Manipulation doesn't work?

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

✓ Accepted answer

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

4 comments

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?

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

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?

0

Nvm, I put both 2nd and 1st script into one function, it worked. Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.