Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Make tool invisible when zooming in first person?

Hey!

I was wondering how to make a tool disappear when zooming in first person (just for the client: its kinda like your character, when zooming in, it disappears but not for the server).

Got any ideas?

Here is my tool structure: Picture (Ignore the tool name)

1 answer

Found it.

script.Parent.Equipped:Connect(function()
	local Player = game.Players.LocalPlayer
	while true do
		wait()
		local cam = game.Workspace.CurrentCamera
		local rs = game:GetService('RunService')

		if (cam.Focus.p-cam.CoordinateFrame.p).magnitude <= 1 then
			local tool = script.Parent
			for i, v in pairs(tool:GetDescendants()) do
		        if v:IsA("BasePart") or v:IsA("UnionOperation") then
		            v.Transparency = 1
		        end
			    end
		else
			local tool = script.Parent
			for i, v in pairs(tool:GetDescendants()) do
		        if v:IsA("BasePart") or v:IsA("UnionOperation") then
		            v.Transparency = 0
		        end
		    end
		end
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.