Vision through walls

hi,

i have made a system from hitman that you can watch the peoples on the map through the wall this is my code:

local vision1 = Instance.new("SurfaceGui")

local visionF = Instance.new("Frame")

local vision2 = vision1:Clone()

local vision2 = visionF:Clone()

local test = math.random(1,6)

script.Parent.MouseButton1Click:Connect(function()

game.Lighting.ColorCorrection.Enabled = true

vision1.Parent = game.Workspace.Goal.Torso

vision1.AlwaysOnTop = true

vision1.Face = "Front"

visionF.Size = UDim2.new(1, 0,1, 0)

visionF.Parent = vision1

visionF.BackgroundColor3 = Color3.fromRGB(163, 162, 165)

end)

but the issue is that when i want that the surface gui is on all body parts i must copy it many times so how can i do that diffrent?

If you want vision through walls use ViewportFrame you can see the actual character not just lines thats harder

just find all bodyparts that is a basepart and the make a table of the Front Left Back Right etc loop through that creating a surfacegui alwaysontop and set the face to the faces that are in the table

local Table = {
    "Bottom",
    "Front",
    etc..
}

grafik
i want that it looks so and not a gui

for face = 0, 5 do
	local gui = Instance.new("SurfaceGui", part)
	gui.Face = face
end

To put it on every bodypart you can use a for loop to iterate all the children of the character

for i, part in pairs(character:GetChildren()) do
    if part:IsA'BasePart' then
        -- apply the surface gui
    end
end

Here:

local Table = {
	"Back",
	"Bottom",
	"Front",
	"Left",
	"Right",
	"Top"
}

for Number, Instance2 in pairs(LocalPlayerCharacter:GetChildren()) do
	if Instance2:IsA("BasePart") then
		for Number, String in pairs(Table) do
			local SurfaceGui = Instance.new("SurfaceGui")
			SurfaceGui.Adornee = Instance2
			SurfaceGui.AlwaysOnTop = true
			SurfaceGui.Face = String
			SurfaceGui.Parent = Instance2
		end
	end
end

Is this what you want?

for Number, Instance2 in pairs(LocalPlayerCharacter:GetChildren()) do
	if Instance2:IsA("BasePart") then
		local BoxHandleAdornment = Instance.new("BoxHandleAdornment")
		BoxHandleAdornment.Adornee = Instance2
		BoxHandleAdornment.AlwaysOnTop = true
		BoxHandleAdornment.Size = Instance2.Size
		BoxHandleAdornment.ZIndex = 0
		BoxHandleAdornment.Parent = Instance2
	end
end

Picture:

image

what is the “LocalPlayerCharacter” variable?

Thats just the character model:

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local LocalPlayerCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()