Trying to change first person camera position (offset)

I have a script where I can see my body in first person and it works well but I can literally see my whole body though:
image
What I want to do is move the camera a little bit forward in first person so I don’t see my whole body. I tried using offset but it does not work as it just constantly moving up and down.

local RunService = game:GetService("RunService");
local Player = game.Players.LocalPlayer;
local Character = Player.Character or Player.CharacterAdded:Wait();
local Camera = game.Workspace.CurrentCamera;
local Head = Character:WaitForChild("Head");

local FPMaximumDistance = 0.6; -- For scalability, but keep it at 0.6 since it is the right distance.
local FirstPersonLocalTransparency = 0;
local ThirdPresonLocalTransparency = 0;

local function SetCharacterLocalTransparency(transparency)
	for i,v in pairs(Character:GetChildren()) do
		if (v:IsA("BasePart")) and (v.Name ~= "Head") then -- Only baseparts have a LocalTransparencyModifier property.
			v.LocalTransparencyModifier = transparency;
		elseif (v:IsA("Accessory")) and (v:FindFirstChild("Handle")) then
			if v.Handle:FindFirstChild("AccessoryWeld").Part1 == Head then

			else
				v:FindFirstChild("Handle").LocalTransparencyModifier = transparency;
			end
		end
	end
end
local h = Player.Character:WaitForChild("Humanoid")
RunService.RenderStepped:Connect(function()
	local isfirstperson = (Head.CFrame.Position - Camera.CFrame.Position).Magnitude < FPMaximumDistance; -- Determine wether we are in first person
	if (isfirstperson) then
		SetCharacterLocalTransparency(FirstPersonLocalTransparency);
	else
		SetCharacterLocalTransparency(ThirdPresonLocalTransparency);
	end
end)

Can you show how it was constantly moving up and down? You would just increase the camera’s position by the LookVector of the Player’s head

Here is a video:


This is the current script:

local RunService = game:GetService("RunService");
local Player = game.Players.LocalPlayer;
local Character = Player.Character or Player.CharacterAdded:Wait();
local Camera = game.Workspace.CurrentCamera;
local Head = Character:WaitForChild("Head");

local FPMaximumDistance = 0.6; -- For scalability, but keep it at 0.6 since it is the right distance.
local FirstPersonLocalTransparency = 0;
local ThirdPresonLocalTransparency = 0;

local function SetCharacterLocalTransparency(transparency)
	for i,v in pairs(Character:GetChildren()) do
		if (v:IsA("BasePart")) and (v.Name ~= "Head") then -- Only baseparts have a LocalTransparencyModifier property.
			v.LocalTransparencyModifier = transparency;
		elseif (v:IsA("Accessory")) and (v:FindFirstChild("Handle")) then
			if v.Handle:FindFirstChild("AccessoryWeld").Part1 == Head then

			else
				v:FindFirstChild("Handle").LocalTransparencyModifier = transparency;
			end
		end
	end
end
local h = Player.Character:WaitForChild("Humanoid")
RunService.RenderStepped:Connect(function()
	local isfirstperson = (Head.CFrame.Position - Camera.CFrame.Position).Magnitude < FPMaximumDistance; -- Determine wether we are in first person
	if (isfirstperson) then
		SetCharacterLocalTransparency(FirstPersonLocalTransparency);
		h.CameraOffset = Vector3.new(0,-3,0)
	else
		SetCharacterLocalTransparency(ThirdPresonLocalTransparency);
	end
end)

I added h.CameraOffset = Vector3.new(0,-3,0), you said to use LookVector, How would i use?

1 Like

Sorry it turned out there was another script interfering with the camera offset, now it works, thanks

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.