0

# How can I move/set the Camera to a certain player?

Edited 1 year ago

The code that I rewritten many times was pretty shit so I was wondering if I could get some help? The script is supposed to pan to the Player if he enters your house.

if (game.Workspace.House.Position - game.Players:GetPlayers().Position).magnitude < 15 then

game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame:Lerp(game.Players:GetPlayers().CFrame)

else

game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom

end

0
I'm assuming this is in a server script. You can only change the camera in a local script DarkDanny04 407 — 1y
0
You can use that same script, but instead of checking using game.Players:GetPlayers() just check for the LocalPlayer, and if their HumanoidRootPart is within distance of the house DarkDanny04 407 — 1y

0
Edited 1 year ago

I had to figured it out myself, thanks a lot guys.

wait(2)

local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
local magnitude = (game.Players.LocalPlayer.Character:FindFirstChild("Head").Position - workspace:FindFirstChild("Part").Position).Magnitude
if magnitude < 15 then
workspace.CurrentCamera.CameraSubject=game.Workspace:FindFirstChild("Part")
else
print(magnitude)
workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
end
end)