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

How can I make a camera connect to a part/object?

I have tried this so far. Basically, the camera will be connected to a part and it will stun the player while it is connected. Tell me what I have wrong, it will be appreciated.

repeat wait() until game:GetService("Players").LocalPlayer.Character ~= nil
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Torso = Character.Torso
local Humanoid = Character:WaitForChild("Humanoid")
local Camera = workspace.CurrentCamera
local NotMoving = true

while NotMoving == true do
    wait()
    Humanoid.WalkSpeed = 0
    Humanoid.Changed:connect(function() Humanoid.Jump  = false end)
    Camera.CameraType = "Scriptable"
	Camera.CoordinateFrame = workspace.CameraPart.CFrame -- CameraPart is the part which the camera will be connected to.
end

2 answers

You need to set the camera subject as well, and the camera subject can be any part, so just do "Camera.CameraSubject = workspace.Camera" and it should work

Also, CoordinateFrame is deprecated and you should replace it with Camera.CFrame instead which is the recommended one to use.

4 comments

0

Not working as well, do you think that where I have placed the script is the matter here? It's in workspace.

0

Yes, you cannot change the camera in a script, it has to be a local script somewhere client-sided for example StarterPack or StarterGui

0

It is not working either.

0

It has to be in a local script

Try changing

Camera.CoordinateFrame

to

Camera.CFrame

also use :Connect instead of :connect for it is deprecated

Note: this script has to be a local script and in a place where it can run on the player (PlayerGui, Backpack)

1 comment

0

Not working. :P

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