How to make first person character body move with camera?

I was using a script that lets you see your body in first person mode.

But it does not work as intended as the body does not move along with camera as it would in regular first person or in third person shiftlock mode.

I tried making a local script that uses tween to fix this. However it does not work and idk why as it doesn’t throw any errors:
Edit: These scripts don’t seem to be causing the error. The script which is causing it is in the replies.

local RunService = game:GetService("RunService")
local tweenService=game:GetService("TweenService")
local Player=game.Players.LocalPlayer
local Character=Player.Character
local part = Character
local goal={c1=workspace.CurrentCamera.CFrame}
local Time=1--second
local info= TweenInfo.new(Time)
local tween=tweenService:Create(part,info, goal)
RunService.RenderStepped:Connect(tween:Play())

The First person Transparency script that I’m using:

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")) then -- Only baseparts have a LocalTransparencyModifier property.
			v.LocalTransparencyModifier = transparency;
		end
	end
end

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)

I also locked it to first person using player.CameraMode = Enum.CameraMode.LockFirstPerson

Here’s a video of my problem

I would appreciate any tips and pointers!

local part = Character
local goal={c1=workspace.CurrentCamera.CFrame}

C1 is not a valid attribute for model, you should set the CFrame of the character’s HumanoidRootPart to the Camera orientation

1 Like

Thanks for your reply. Following your advice (or at least attempting to follow) I tried few other solutions:

local part = Character.HumanoidRootPart
local goal={}
goal.CFrame=game.Workspace.CurrentCamera.CFrame
local Time=1--second
local info= TweenInfo.new(Time)
local tween=tweenService:Create(part,info, goal)
RunService.RenderStepped:Connect(function()
	tween:Play()
end)

This resulted in:

Then I tried:


goal.Orientation=game.Workspace.CurrentCamera.CFrame.LookVector

end)

Which resulted in:

Then

goal.Orientation=game.Workspace.CurrentCamera.CFrame.Position

I must admit, these results are quite funny to look at. At least they are in the general direction of what I’m trying to make. But I would certainly appreciate more input though!

Try adding this to your LocalScript

UserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.CameraRelative
1 Like

Thanks for the reply! I have tried using it by its own and using it in conjunction with my other attempts. Unfortunately it did not provide a different outcome than the ones I have documented

It seems that none of the scripts I’ve mentioned are causing the problem… This was a huge mistake on my part as all the videos I’ve captured are after I used another script. Now Idk if I should close this thread and open a new one cuz the problem is still the same but with different context. But I also don’t wanna hijack my own thread. If you have any suggestions please let me know. The script that was causing the problem:

function moveCamera(offset)
	local TweenTime = 3 -- How long the camera will be moving for
	local GoalPart = char:FindFirstChild("Head")-- The part the camera will move toward. It's important to use a part here rather than a position because we need to get the part's position at every frame in case it changes.
	local InitialCFrame = workspace.CurrentCamera.CFrame

	-- Do not change the below variables.
	local DeltaTime = 0 -- The time at each frame between when the animation starts and ends.
	local InitialTime = time() -- The time the animation started.
	local RenderStepped = game:GetService("RunService").RenderStepped

	local Success, CameraSubjectPosition = pcall(function() -- Here we are trying to get the current position of the CameraSubject part so we can use it to preserve the distance between the camera and the current CameraSubject.
		return workspace.CurrentCamera.CameraSubject.Position -- If CameraSubject is a part
	end)

	if not Success then
		Success, CameraSubjectPosition = pcall(function() -- Here we are trying again a different way if the first one didn't work, reusing the last attempt's variables.
			return workspace.CurrentCamera.CameraSubject.Parent.Head.Position -- If CameraSubject is a humanoid in a typical character
			-- Roblox really needs a Humanoid.CameraPart or some such property
		end)
	end

	if not Success then
		return -- Give up if we couldn't find the actual CameraSubject part.
	end

	local ZoomVector = CameraSubjectPosition - workspace.CurrentCamera.CFrame.Position -- This is the distance between the camera and initial part (most likely your head).
	local InitialOrientation = InitialCFrame - InitialCFrame.Position -- We record the initial camera CFrame's orientation so the camera rotation doesn't change during the animation.

	while DeltaTime <= TweenTime do -- The loop continues until the TweenTime has finished
		RenderStepped:Wait() -- Yield for the next frame.
		DeltaTime = time() - InitialTime -- Refresh the time differential ("between-time")
		local GoalPositionInitialOrientation = InitialOrientation + (GoalPart.Position - ZoomVector)
		-- In the above line, we construct a CFrame where an imaginary camera is looking at the goal part from the same distance and with the same rotation as our actual camera was looking at the previous CameraSubject.
		local Percent = DeltaTime / TweenTime -- Get a number from 0 to 1 representing a percentage of how close we are to finishing the animation
		local DeltaCFrame = InitialCFrame:Lerp(GoalPositionInitialOrientation, Percent) -- The CFrame the camera will snap to during this frame
		workspace.CurrentCamera.CFrame = DeltaCFrame -- Actually move the camera here.
	end

	workspace.CurrentCamera.CameraSubject = GoalPart
end

I was using it to move my character to its head position after crouching and uncrouching. After I fire this function the body stops moving along with the camera.

I finally found the solution. Can’t believe I didn’t find this before:- What would be the best way to force a First-Person perspective alongside Motor6 modification?

1 Like