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

My code is not changing the camera's Cframe?

Asked by
Cikeruw 14
1 year ago

My code is supposed to mimic shift lock. But the camera is not changing for some reason. Could someone please help me out?

Here is my code:

local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer


-- Listen for the player's character changing
player.CharacterAdded:Connect(function(character)
    wait(5)
    print("here")
    print(camera.CFrame)
    camera.CFrame = camera.CFrame * CFrame.new(1.7,0,0)
    print(camera.CFrame)
end)

1 answer

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
1 year ago

You need to make sure the CameraType is scriptable.

local Player = game:GetService('Players').LocalPlayer
local Camera = workspace.CurrentCamera

local Character = Player.Character or Player.CharacterAdded:Wait()

task.wait(5)
print('here')
print(Camera.CFrame)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = Camera.CFrame * CFrame.new(1.7,0,0)
print(Camera.CFrame)
0
I figured this out but how do i make the camera follow the player Cikeruw 14 — 1y
Ad

Answer this question