Need help making the legs and torso visible in first person

I’ve been trying to make a script which shows the torso and legs visible in first person, and i haven’t gotten any results. Originally it was a first person body script, but i scraped it since i made a view-model for the movement in first person. But, i tried editing my script but i got no luck.

local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

char.Humanoid.CameraOffset = Vector3.new(0, 0, -5)

for i, v in pairs(char:GetChildren()) do
	if v:IsA("BasePart") and v.Name ~= "Head" then

		v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
			v.LocalTransparencyModifier = v.Transparency
		end)

		v.LocalTransparencyModifier = v.Transparency

	end
end

RunService.RenderStepped:Connect(function(step)
	local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
	local ignoreList = char:GetChildren()

	local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)

	if hit then
		char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
	else
		char.Humanoid.CameraOffset = Vector3.new(0, 0, -2)
	end
end)

and here’s my try at editing it:

local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

char.Humanoid.CameraOffset = Vector3.new(0, 0, -5)

for i, v in pairs(char:GetChildren()) do
	if v:IsA("BasePart") and v.Name ~= "Head" or "Arm" then

		v:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
			v.LocalTransparencyModifier = v.Transparency
		end)

		v.LocalTransparencyModifier = v.Transparency

	end
end

RunService.RenderStepped:Connect(function(step)
	local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
	local ignoreList = char:GetChildren()

	local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)

	if hit then
		char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
	else
		char.Humanoid.CameraOffset = Vector3.new(0, 0, -2)
	end
end)

When i didn’t edit the script, it worked completely fine.
But, when i edited the script to make it work, it didn’t show anything.
If i could get some help, i would really appreciate it!

3 Likes

I actually rechecked the normal unedited script in my game, and it doesn’t work. Must be a problem with the scripts.

1 Like

This already got solved before. Here is the link to the solution.

The solution itself by Exeplex:

If you only want the torso and the legs to show
(assuming you’re using r6),
you should change the condition in the SetCharacterLocalTransparency from

(v:IsA("BasePart")) 

To

(v:IsA("BasePart")) and v.Name ~= "Right Arm" or "Left Arm"
4 Likes

I tried the script, it didn’t do anything.

1 Like

The problem might have to do with the character not loading. Here is the code:

local RunService = game:GetService("RunService");
local player = game.Players.LocalPlayer;
task.wait(2)
local character = player.Character character = player.Character character = player.Character
if character then
	character = player.Character
else
	character = player.Character
end
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 ~= "Right Arm" or "Left Arm" 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)

Here I have replaced

local Character = Player.Character or Player.CharacterAdded:Wait();

with

task.wait(2)
local character = player.Character character = player.Character character = player.Character
if character then
	character = player.Character
else
	character = player.Character
end

This ensures that local character = player.Character after the character has loaded in.
Also be sure to make it a localscript.

3 Likes

Are you using a local script or a server script? I’m guessing it should be local since the player is only watching themself in first person.

3 Likes

Yup, i used a local script. I dont think people would want to see a headless man.

so i managed to edit most of your script to make it work! Thanks for the coee though. It helped alot.

1 Like

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