I made a KeyDown script that toggles invisibility for a character. Everything works fine, except I'm struggling to hide the player's face so it's not just floating around in mid-air. Any suggestions on how I would do that?
player = game.Players.LocalPlayer
mouse = player:GetMouse()
repeat wait() until player.Character
char = player.Character
faic = char.Head.face
char.Humanoid.DisplayDistanceType = "Viewer"
debounce = false
invisible = false
function invisibility()
for x = 0, 2*math.pi, .1*math.pi do
local waveform = 1/2-(math.cos(x/2)/2)
for _, v in pairs(char:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then v.Transparency = waveform
elseif v:IsA("Hat") and v.Handle then v.Handle.Transparency = waveform end
end
wait()
end
char.Humanoid.HealthDisplayDistance = 0
char.Humanoid.NameDisplayDistance = 0
invisible = true
end
function visibility()
char.Humanoid.HealthDisplayDistance = 100
char.Humanoid.NameDisplayDistance = 100
for x = 2*math.pi, 4*math.pi, .1*math.pi do
local waveform = 1/2-(math.cos(x/2)/2)
for _, v in pairs(char:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then v.Transparency = waveform
elseif v:IsA("Hat") and v.Handle then v.Handle.Transparency = waveform end
end
wait()
end
invisible = false
end
function onKeyDown(key)
if key == "x" then
if debounce == false then
debounce = true
if invisible == false then invisibility()
elseif invisible == true then visibility() end
debounce = false
end
end
end
mouse.KeyDown:connect(onKeyDown)
