Make Character invisible when zoomed in

Hello!

How would I go about making the character invisible when zoomed in because this is what happens.


BTW I am using skinmesh.

BasePart.LocalTransparencyModifier (roblox.com)

How would I detect if I were in first person?

I found a post that may help you. Want to make my whole body visible, but my hands are still invisible - Help and Feedback / Scripting Support - DevForum | Roblox

So I used this post How can I detect how much zoomed in a player is? to detect if the player is zoomed in for anyone else in the future.

When you say zoomed in, is this when you use the mouse wheel to move the camera into the players head? This could be hard to hook, you may have to check the camera on some frame stepper to make things disappear when it reaches some threshold. Boris gave a neat solution to making things invisible with the link he provided, although it does say that this is not recommended for every day use since it may be subject to change, but again you would have to hook some property on the camera and check this regularly in a loop or on a frame stepping method. You could manually position the camera when the user presses a button (like a zoom mode) then you can control what they see when they are in this mode by moving the camera into the head and push it forward a little beyond the head so they don’t see the hat/goggles.

Gah, I just wrote a massive answer. That is why people really should have a good look around for solutions on the forum before asking the question in the first place. Waste of time, I understand now why this is a thing! And to be honest I think they do it so they can solve their own posts and bump the solutions count.

Sorry that I wasted your time but I can assure you what you said was not my intention. The post Boris made gave my brain something else to search up because before I searched up. “How to make character invisible when zoomed in” I then searched up “How to detect if player is zoomed in” Once again sorry : (

1 Like

No worries mate, sometimes time and the universe just works against you. The best method to find stuff is search Google and not Roblox’s in-built search. I usually would have searched Google for “Roblox how to make character invisible”. You get a better selection that way.

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

local function OnRenderStep()
	local Distance = (Camera.CFrame.Position - Head.Position).Magnitude
	for _, Descendant in ipairs(Character:GetDescendants()) do
		if not (Descendant:IsA("BasePart")) then continue end
		Descendant.Transparency = 1 - ((Distance - 0.5) / 127.5)
	end
end

RunService.RenderStepped:Connect(OnRenderStep)

Well I wrote a script for this and worked out some of the math for you.