Make camera follow head in first person with accessories invisible

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Making the camera follow the head in first person without camera offsets. Also, make all the accessories invisible.

  2. What is the issue? Can’t figure it out.

  3. What solutions have you tried so far? I have tried a lot, looked at the dev forum, writing my own code, etc etc.

Simple First Person Mode

About
This is my simplest first person mode I made.
It makes you go into the first person, putting your camera on the head and making accessories
invisible. Accessories of the player will be invisible only to him, other players will be able to see them. Also script takes 2 seconds to load.

How to make it work
To make it work, create a localscript (for example FirstPersonMode) in a game.StarterPlayer.StarterCharacterScripts and put in this script.

Script

local runService = game:GetService("RunService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera

wait(2)
for _, child in pairs(character:GetDescendants()) do
	if child:IsA("Accessory") then
		for _, accessory in pairs(child:GetChildren()) do
			accessory.Transparency = 1
		end
	end
end

currentCamera.CameraSubject = character:WaitForChild("Head")
player.CameraMinZoomDistance = 0
player.CameraMaxZoomDistance = 0

runService.RenderStepped:Connect(function()
	local x1, y1, z1 = currentCamera.CFrame:ToOrientation()
	local x2, y2, z2 = character.PrimaryPart.CFrame:ToOrientation()
	character.PrimaryPart.CFrame *= CFrame.Angles(0, y1 - y2, 0)
end)

If you want you can also just take my model here:

and you can leave a comment what you think about it.

If you have any other questions, feel free to ask.

1 Like

I’m sorry I was sleeping since I wasn’t feeling so well. I’ll try it out now.

It works though it gives this error: Transparency is not a valid member of Configuration “Workspace.kolmatinsweden.AnimeShortHairAccessory10.ThumbnailConfiguration”

I fixed the error though it doesn’t follow the head all of the time. I have a running animation in which you can see a bit of the back of the head.

my code:

local runService = game:GetService("RunService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera

wait(2)
for _, child in pairs(character:GetDescendants()) do
	if child:IsA("Accessory") then
		for _, accessory in pairs(child:GetChildren()) do
			for _, part in pairs(child:GetChildren()) do
				if not part:IsA("Configuration") then
					part.Transparency = 1
				end
			end
		end
	end
end

currentCamera.CameraSubject = character:WaitForChild("Head")
player.CameraMinZoomDistance = 0.5
player.CameraMaxZoomDistance = 0.5

runService.RenderStepped:Connect(function()
	local x1, y1, z1 = currentCamera.CFrame:ToOrientation()
	local x2, y2, z2 = character.PrimaryPart.CFrame:ToOrientation()
	character.PrimaryPart.CFrame *= CFrame.Angles(0, y1 - y2, 0)
end)

This should go into community resources.

1 Like

No, since it started as me needing help.

1 Like

Well, animation is animation, its not head actually moving
you can make head invisible, that will fix it abit.

New script

local runService = game:GetService("RunService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local currentCamera = game.Workspace.CurrentCamera

wait(2)
for _, child in pairs(character:GetDescendants()) do
	if child:IsA("Accessory") then
		for _, accessory in pairs(child:GetChildren()) do
			if accessory:IsA("MeshPart") then
				accessory.Transparency = 1
			end
		end
	elseif child.Name == "Head" and child:IsA("MeshPart") then
		child.Transparency = 1
	end
end

currentCamera.CameraSubject = character:WaitForChild("Head")
player.CameraMinZoomDistance = 0
player.CameraMaxZoomDistance = 0

runService.RenderStepped:Connect(function()
	local x1, y1, z1 = currentCamera.CFrame:ToOrientation()
	local x2, y2, z2 = character.PrimaryPart.CFrame:ToOrientation()
	character.PrimaryPart.CFrame *= CFrame.Angles(0, y1 - y2, 0)
end)

I will rework it once more so that your camera will actually be a bit in front, so you wont see the top of your head, and add a neck movement (maybe also a function that while you hold, lets say left alt key, you will be able to move your mouse on the screen).

1 Like

Good Idea, I’ll make it as community resource later

I made a new script for it, now It fixes that problems, but only works with R15 type for now. for more info check: First Person Mode [V1.0]

Sad, my game is in r6 not r15.

Im working on a fix for this, stay tuned.

What!??!? Are you sure? This is a lot of work for a stranger on the internet! :open_mouth:

Lol, I like the idea to have a first person mode, also, I’m almost done with coding it so that it would work with R6 too.

Put it in community resources too would probably help a lot of people and not just me :sweat_smile:

I did already, I will update it in a minute, you can find it here

1 Like

Alright, just reply when it’s done :smiley:

Its finally updated and out. Now it works both with R15 and R6. Go check it out:

3 Likes

Thank you!!! You really are a legend.

though one little bug: Infinite yield possible on ‘Players.kolmatinsweden.PlayerGui:WaitForChild(“FirstPerson”)’