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

Any way to follow player but keep the same distance?

Asked by
zomspi 541 Moderation Voter
4 years ago

I am making a camera script and have made it so it follows the player (in a 2D game). Although it is not the effect I hoped. It isn't really 2D when my player can move left, right, forward and backward with the camera following. I want my players to be able to do those things but not with the camera following them. So basically I want to make the camera only able to move left and right.

I was wondering if this is actually possible and if so, how?

Thanks!

0
Hi, could you show us what you have make so far of your script? WideSteal321 773 — 4y

1 answer

Log in to vote
0
Answered by
zomspi 541 Moderation Voter
4 years ago
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera



player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")

camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Attach
camera.FieldOfView = 70

game:GetService("RunService").Stepped:Connect(function()
    camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,5,20)
end)






I got it from a vid and added some stuff

0
use a loop to check if the camera is a certain distance from the player DeceptiveCaster 3761 — 4y
0
how do I check the distance? zomspi 541 — 4y
Ad

Answer this question