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

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

Asked by 4 years ago
Edited 4 years 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 — 4y
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 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years 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