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

I have a loop that loops through every player in the game and sets their parts to invisible via transparency, but when I run through again and set them back to visible, their humanoidrootparts are visible too… I want to keep the script running as is, but I just want the humanoidrootpart to return back to invisible


EDIT: For those who have a similar question to the one I asked in the title, the soution user said this:

if part.Name == "HumanoidRootPart" then continue end --This answears your main question

The post solution is for making players invisible and reappear :slight_smile:

not exactly, but you can just do

if not thing:IsA("THING") then

this should yield the right result if I understood correctly

2 Likes

Am I getting the right idea here…? :sweat_smile:

local hide = true

local orignalTransparency = {}

local function checkPart(part)
	for a,b in pairs(part:GetChildren()) do 
		checkPart(b)
	end
	if part:IsA("BasePart") or part:IsA("Decal") and not part:IsA("HumanoidRootPart") then
		if hide then
			if not orignalTransparency[part] then
				orignalTransparency[part] = part.Transparency
			end
			part.Transparency = 0
		else 
			if orignalTransparency[part] then
				part.Transparency = orignalTransparency[part]
				orignalTransparency[part] = nil 
			end
		end
	end
end

EDIT: oops I did what you told me wrong… I just realized lol

wait is HumanoidRootPart an actual class? (Omg this is the best day ever)
From looking at your code it seems right except you might want to do this instead:

if (part:IsA("BasePart") or part:IsA("Decal")) and not part:IsA("HumanoidRootPart") then

When it comes to if statements and using or’s and using an and, its best to put the OR stuff into the () that way it doesnt act silly

1 Like

This didn’t seem to work for some reason, no errors in the output either. Do you think it would be easier to loop back through the players again after the other script has run to set the HumanoidRootPart’s transparencies to invisible again?

Idk tbh, try it and lets see what happens

1 Like

As far as I know, HumanoidRootPart isn’t an actual class, so you cannot use :IsA() to check if a part is an HRP. You will have to check if the name of the part isn’t “HumanoidRootPart” instead. Something like part.Name ~= "HumanoidRootPart".

1 Like

Oh I see, yeah I figured it had something to do with that but I am a total noob when it comes to these type of scripts…

Let me try this rq…

1 Like

I’m frying my brain, I am defo doing something wrong still haha

local function checkPart(part)
	for a,b in pairs(part:GetChildren()) do 
		checkPart(b)
	end
if (part:IsA("BasePart") or part:IsA("Decal")) and not part.Name == "HumanoidRootPart" then 
		if hide 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

I would recommend wrapping part.Name == "HumanoidRootPart" in parentheses like so.
… and not (part.Name == "HumanoidRootPart") then
Or you can simply do this:
… and part.Name ~= "HumanoidRootPart" then

1 Like

Ahh, I tried both, no errors in output… HRP still there :smiling_face_with_tear:
image
I asked this previously to someone else… but do you think looping through in a new script to set the HRP visible again would work and be easier?

The HumanoidRootPart (HRP), is just a regular BasePart that roblox’s engine (from my understanding) uses to position, move, and animate the character. You arent able to use IsA for this because it is not some special instance, just a regular ol’ brick.

Maybe try to reference the HRP from the humanoid instance’s Humanoid.RootPart property, or use Character.PrimaryPart.

local function checkPart(part)
	for a,b in pairs(part:GetChildren()) do 
		checkPart(b)
	end
if (part:IsA("BasePart") or part:IsA("Decal")) and not (part == Humanoid.RootPart or part == Character.PrimaryPart) then 
		if hide 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
1 Like

Did some testing; and i think it should work.

Test Code:

local char = game.Players.LocalPlayer.Character
local humanoid = char:FindFirstChildOfClass("Humanoid")

local function check()
	if char then
		for _, v in pairs(char:GetChildren()) do
			if (v:IsA("BasePart") or v:IsA("Decal")) and not (v == humanoid.RootPart or v == char.PrimaryPart) then
				print(v.Name.." is not the HRP")
			elseif (v:IsA("BasePart") or v:IsA("Decal")) and (v == humanoid.RootPart or v == char.PrimaryPart) then
				print(v.Name.." is the HRP")
			end
		end
	end
end

check()

Output:

  10:22:54.170  Head is not the HRP  -  Client - LocalScript:8
  10:22:54.170  Torso is not the HRP  -  Client - LocalScript:8
  10:22:54.170  Left Arm is not the HRP  -  Client - LocalScript:8
  10:22:54.170  Right Arm is not the HRP  -  Client - LocalScript:8
  10:22:54.171  Left Leg is not the HRP  -  Client - LocalScript:8
  10:22:54.171  Right Leg is not the HRP  -  Client - LocalScript:8
  10:22:54.171  HumanoidRootPart is the HRP  -  Client - LocalScript:10
1 Like

Here is how I applied it to mine, if I even did it correctly haha.

I should have done this a while ago, but this is the entire script, I didn’t think it was needed with my original question…

local hide = true
local orignalTransparency = {}

local char = game.Players.LocalPlayer.Character
local humanoid = char:FindFirstChildOfClass("Humanoid")

local function checkPart(part)
	if char then
		for _, v in pairs(char:GetChildren()) do
			if (v:IsA("BasePart") or v:IsA("Decal")) and not (v == humanoid.RootPart or v == char.PrimaryPart) then 
		if hide 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
end

local players = game:GetService("Players")
local localPlayer = players.LocalPlayer

game:GetService("RunService").RenderStepped:Connect(function() 
	for i,v in pairs(players:GetPlayers()) do 
		if v ~= localPlayer then 
			local char = v.Character
			if char then
				checkPart(char)
			end
		end
	end
	for part,trans in pairs(orignalTransparency) do
		if not part then
			orignalTransparency[part] = nil
		elseif not part.Parent then
			orignalTransparency[part] = nil
		end
	end
end)

Wouldn’t this also make it so it would print “Head is the HRP”?

image
Seeing as Roblox pushed an update that made the PrimaryPart of new rigs (and characters) the Head.

1 Like

Uhhh try this, cleaned it up a bit too

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 --This answears your main question
		
		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(23)
toHide = not toHide
print("Appear!")
1 Like

Hm, fair point. Maybe just not use the Character.PrimaryPart then I guess and just stick to Humanoid.RootPart. I’d also say the RootPart property is fool proof because a humanoid REQUIRES a RootPart in the first place to even do anything, unless I haven’t caught up onto some news about humanoids :confused: .

1 Like

Ahh I tried this and the HRP is still visible :face_with_spiral_eyes:

Are you sure there isn’t another thing interfering with the script?
I tested my code and the HRP does not show when the player becomes visible

1 Like

Omg, yes sorry there was a script messing with it haha… but it seems to not make accessories invisible :rofl: bit of a jump scare
image

edit: Or maybe this is another me issue? Let me try on a blank world…

1 Like