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

Why is the camera not following my mouse lookvector?

Asked by 5 years ago
wait(1)

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
mouse.Move:Connect(function()
camera.CFrame = CFrame.new(mouse.Hit.lookVector * 5)
print(CFrame.new(mouse.Hit.lookVector * 5))
end)

Why is the camera stuck in position and is not following the camera? the printed message changes when i move the mouse,but not the camera.

1 answer

Log in to vote
1
Answered by
Prestory 1395 Moderation Voter
5 years ago
Edited 5 years ago

You need to set the camera type to CameraType.Scriptable if you do not set it to Scriptable you are not allowed to edit the camera using a script

wait(1)

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
camera.CameraType = Enum.CameraType.Scriptable

mouse.Move:Connect(function()
camera.CFrame = CFrame.new(mouse.Hit.lookVector * 5)
print(CFrame.new(mouse.Hit.lookvector * 5))
end)
0
Could you explain why it doesn't work without it? Thepoint13 99 — 5y
Ad

Answer this question