Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 1 month ago
Edited 1 month 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 392 — 1mo
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 392 — 1mo

1 answer

Log in to vote
0
Answered by 1 month ago
Edited 1 month 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)
Ad

Answer this question