Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Any way to follow player but keep the same distance?

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!

1 comment

0

Hi, could you show us what you have make so far of your script?

1 answer

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

2 comments

0

use a loop to check if the camera is a certain distance from the player

0

how do I check the distance?

This discussion is preserved as it was. New answers, comments, and votes are closed.