✓ Accepted answer
Alright, let me explain what you're having a problem with, there are a couple
for i,Child in pairs(Character:GetChildren()) do
if Child:IsA('Part') or Child:IsA('MeshPart') then
Child.Transparency = 1
end
end
- All you're doing is getting the Children of the character which that only gets the main body parts and the accessories themselves. In order for that to work, you'd need to get their children aswell
if Child:IsA('Accessory') then
Child.Transparency = 1
end
- Accessories do not have a transparency themselves... Just their BasePart children within it.
local Players = game:GetService('Players')
local function InvisibleCharacter(Character)
for i,child in pairs (Character:GetDescendants()) do
if child:IsA('BasePart') or child:IsA('Decal') then
local a = Instance.new('NumberValue')
a.Value = child.Transparency
a.Name = 'ItemTransparency'
a.Parent = child
child.Transparency = 1
end
end
print(Character.Name,'Is now invisible')
end
local function VisibleCharacter(Character)
for _,child in pairs (Character:GetDescendants()) do
local originalTransparency = child:FindFirstChild('ItemTransparency')
if originalTransparency then
child.Transparency = originalTransparency.Value
originalTransparency:Destroy()
end
end
print(Character.Name,'Is now visible')
end
local function CharacterAdded(Character)
wait()
InvisibleCharacter(Character)
end
Players.PlayerAdded:Connect(function(Player)
if Player.Character then
CharacterAdded(Player.Character)
end
Player.CharacterAdded:Connect(CharacterAdded)
end)
Alright, what I have done here is set it up for you.. I want you to learn from this... so
What this does is it gets their character whenever it's added and gets the Descendants of Character(Checking if it's a basepart or Decal) and saves all of it's current transparency under a number value named 'ItemTransparency' which we call back later when we want to revert the process(Making the character visible again)
you make the character Invisible by calling function InvisibleCharacter() -- with the argument being the player.Character
you make the character Visible again by calling function VisibleCharacter() -- again with the argument being the player.Character
All the Visible function does is loops through the descendants like before, but instead of checking if it's a basepart or not, it goes through looking for that 'ItemTransparency' Number value we added in before and set the part/decals transparency back to what it previously was set to.
If you still have any questions, feel free to ask! Hope this helps :)
3 comments
Hello, thanks for your contribution! I really appreciate your time! anyway, I am having trouble on why it makes all players invisible when I am only trying to make the clients character the only one visible, what i am trying to say is to the player, everyone else is invisible except for them, I am sorry if your answer solves this but I am being dumb and if that is the case one more [p1]
push in the right direction would be honestly really great, these comments aren't doing me much justice lol so if you want you could message me on discord if not that is still fine. Thank you!
Alright, I'm still a little confused on exactly what you're wanting lol. But yeah I'll add you on discord and we can chat there