This might sound dumb.. but is there a opposite version of IsA? Like IsNot?

Here it is altered for accessoriables

local PlayerService = game:GetService("Players")
local RunService = game:GetService("RunService")

local localPlayer = PlayerService.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()

local toHide = true
local orignalTransparency = {}

local function CheckPart(character :Model)
	for _, part in character:GetChildren() do
		if part.Name == "HumanoidRootPart" then continue end
	
		if part:IsA("Accessory") then
			local handle = part.Handle
			
			if toHide then
				if not orignalTransparency[handle] then
					orignalTransparency[handle] = handle.Transparency
				end
				handle.Transparency = 1
			else
				if orignalTransparency[handle] then
					handle.Transparency = orignalTransparency[handle]
					orignalTransparency[handle] = nil
				end
			end
			
			continue
		end
		
		if part:IsA("BasePart") or part:IsA("Decal") then
			if toHide then
				if not orignalTransparency[part] then
					orignalTransparency[part] = part.Transparency
				end
				part.Transparency = 1
			else
				if orignalTransparency[part] then
					part.Transparency = orignalTransparency[part]
					orignalTransparency[part] = nil
				end
			end
		end
		
	end
end

RunService.RenderStepped:Connect(function()
	for _, player in PlayerService:GetPlayers() do
		if player ~= localPlayer then
			local character = player.Character
			if character then
				CheckPart(character)
			end
		end
	end
	
	for part, transparency in orignalTransparency do
		if not part then
			orignalTransparency[part] = nil
		elseif not part.Parent then
			orignalTransparency[part] = nil
		end
	end
end)

print("Hiding!")
task.wait(13)
toHide = not toHide
print("Appear!")
1 Like

I appreciate the help!! 🩷 The only issue I ran into is the decal face being visible - which confuses me because we did loop through for decals specifically for the face… :thinking:

image

Again I really do appreciate the time you’re taking to help me :smile:

Alright so when you looped for decals, it is getting the player’s children
GetChildren() Character -> Head

Not the descendants
GetDescendants() Character -> Head -> Face

But descendants would be using more performance so we gotta use FindFirstChild Instead, yea
And decals wouldn’t be parented to the character as decals need a BasePart to show itself

Also, I cleaned it up again cause copy+pasting the if toHide and orignalTransparency[part] is tedious. So, it’s now a function!!!

local PlayerService = game:GetService("Players")
local RunService = game:GetService("RunService")

local localPlayer = PlayerService.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()

local toHide = true
local orignalTransparency = {}

local function UpdateTransparency(part)
	if not part then return end
	
	if toHide then
		if not orignalTransparency[part] then
			orignalTransparency[part] = part.Transparency
		end
		part.Transparency = 1
	else
		if orignalTransparency[part] then
			part.Transparency = orignalTransparency[part]
			orignalTransparency[part] = nil
		end
	end
end

local function CheckPart(character :Model)
	for _, part in character:GetChildren() do
		if part.Name == "HumanoidRootPart" then continue end
	
		if part:IsA("Accessory") then
			UpdateTransparency(part.Handle)
			continue
		end
		
		if part:IsA("BasePart") then
			UpdateTransparency(part)
			
			local face :Decal = part:FindFirstChild("face")
			if face then
				UpdateTransparency(face)
			end
		end
	end
end

RunService.RenderStepped:Connect(function()
	for _, player in PlayerService:GetPlayers() do
		if player ~= localPlayer then
			local character = player.Character
			if character then
				CheckPart(character)
			end
		end
	end
	
	for part, transparency in orignalTransparency do
		if not part then
			orignalTransparency[part] = nil
		elseif not part.Parent then
			orignalTransparency[part] = nil
		end
	end
end)

print("Hiding!")
task.wait(13)
toHide = not toHide
print("Appear!")
1 Like

You’re literally god-sent… :sob: :pray: I’ve only been scripting for about 2-3 months so this helps a lot, I will definitely be referring to this script a lot in the future. 🩷🩷🩷🩷

2 Likes

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