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

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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.

0
Not working as well, do you think that where I have placed the script is the matter here? It's in workspace. SwingingMelons -18 — 5y
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 YabaDabaD0O 505 — 5y
0
It is not working either. SwingingMelons -18 — 5y
0
It has to be in a local script T1mes 230 — 5y
Ad
Log in to vote
0
Answered by
T1mes 230 Moderation Voter
5 years ago
Edited 5 years ago

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)

0
Not working. :P SwingingMelons -18 — 5y

Answer this question