Hey developers!
So I am creating a cloaking system than activates when “F” is pressed.
The system works just fine except for the HumanoidRootPart becoming visible when they become visible again. I have tried to counter this but it has proved unsuccessful…
Here is my code from a ModuleScript:
local turnInvisible = {}
function turnInvisible.turn(player)
local character = player.Character
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") or part:IsA("Accessory") or part:IsA("Decal") then
part.Transparency = 1
end
end
end
function turnInvisible.normal(player)
local character = player.Character
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") or part:IsA("Accessory") or part:IsA("Decal") and not part.Name == "HumanoidRootPart" then
part.Transparency = 0
end
end
end
return turnInvisible
If you know how to fix this please reply!
Thank you 
If you want to check if something is not something else and is not a boolean, you do this
and part.Name ~= "HumanoidRootPart"
Maybe try this?
1 Like
Ok I tried that and it still becomes visible when I turn visible again.
Okay I see anotehr thing why it could be that, change your if statement from this
if part:IsA("BasePart") or part:IsA("Accessory") or part:IsA("Decal") and not part.Name == "HumanoidRootPart" then
To this
if (part:IsA("BasePart") or part:IsA("Accessory") or part:IsA("Decal")) and part.Name ~= "HumanoidRootPart" then
Could be the or
s conflicting, so you should put them all in a bracket and leave the last part bracketless. Because the ors wil ltell it “if it’s true, continue”, and a part is definitely going to be a BasePart in a character so it will be true and thus skip the other checks
1 Like
That actually worked, didn’t think that the or’s would conflict like that.
Thank you!
1 Like
Anytime! If you have anymore issues don’t be afraid to make another post!
1 Like
Hello, how are you doing?
Try changing this line into this:
if part:IsA("BasePart") or part:IsA("Accessory") or part:IsA("Decal") then
if part.Name ~= "HumanoidRootPart" then
part.Transparency = 0
end
end
Hope i’ve helped!
Sorry but my question was already solved.
Thanks anyways!
1 Like
No problem, glad you’ve found the solution!