I get that I'll need to use a local script but beyond that how can I achieve this? I want this effect to be on every single player.
How can I make all humanoids appear 0.5 transparent but each player sees themselves as opaque?
2 answers
local player = game.Players.LocalPlayer
local character=player.Character or player.CharacterAdded:Wait()
character:WaitForChild("HumanoidRootPart")
local disappear=function(TargetChar)
for i, v in pairs(TargetChar:GetChildren()) do
if v.ClassName=="MeshPart" or v.ClassName=="Part" then
v.Transparency = 0.5
end
if v.ClassName=="Accessory" then
v.Handle.Transparency=0.5
end
end
end
disappear(character)
player.CharacterAdded:Connect(function(char)
disappear(char)
end)
for i, v in pairs(game.Players:GetChildren()) do
disappear(v)
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
disappear(char)
end)
end)
Try that!
11 comments
Do not make code-only answers.
It's all good, I am fine with it and they can do it if they want, I hardly add comments bc they copy anyway.
Ah smart man! This is very helpful, it's almost perfect, only problem is it works in reverse, your character is transparent but you see everyone else as opaque.
Ohhh you want everyone to be opaque?
Use a remote event for that one!
If you'd like, accept this answer ;D
Remote Events aren't necessary.
Ya I just want everyone to see themselves as opaque while everyone else sees them as transparent, I'll look into a remote event. Thanks for the help. How do I say my question is answered?
RemoteEvents aren't necessary at all. They don't need to be used for this task.
Not sure if you'll get this Rinpix, but you're answer got deleted and I just wanted to tell you that you're script and explanation were both tremendously helpful (I'm quite new to this type of coding), but the script has an issue where it only works on people who join after you and not the people already in game. Hmu if you see this or have a solution, if not thanks for the dedicated time and help
I deleted it because I thought I was dealing with a technical problem and figured the answer was unreachable at least by me. I figured it out after I deleted it and reposted. Sorry to flood your notifications, though.
Initially, I deleted my response because I thought there was going to be a technical problem that I couldn't identify, but I got it to work.
Same thing as last time, put this code inside of a LocalScript inside of StarterPlayer:
local player = game:GetService("Players").LocalPlayer
local character = (player.Character) or (player.CharacterAdded:Wait())
character:WaitForChild("HumanoidRootPart")
local function modifyTransparency(otherPlayer, otherPlayerCharacter)
if ((otherPlayer) and (otherPlayer ~= player) and (otherPlayerCharacter)) then
otherPlayerCharacter:WaitForChild("HumanoidRootPart")
for i, d in pairs(otherPlayerCharacter:GetDescendants()) do
if (d:IsA("BasePart") and (d.Name ~= "HumanoidRootPart")) then
d.Transparency = 0.5
end
end
end
end
for i, otherPlayer in pairs(game.Players:GetPlayers()) do
if (otherPlayer.Character) then
modifyTransparency(otherPlayer, otherPlayer.Character)
end
otherPlayer.CharacterAdded:Connect(function()
modifyTransparency(otherPlayer, otherPlayer.Character)
end)
end
game.Players.PlayerAdded:Connect(function(otherPlayer)
otherPlayer.CharacterAdded:Connect(function()
modifyTransparency(otherPlayer, otherPlayer.Character)
end)
end)
The function first ensures that the player passed in is not the same player as the client. Once it has ascertained that, it iterates through every BasePart of the character, except for the HumanoidRootPart, which would look odd if its transparency was set to 0.5 as it has a transparency of 1 by default and isn't meant to be seen. The instances that are BaseParts and are also not the HumanoidRootPart have their transparency set to 0.5.
The for loop just underneath the function iterates through every player in the server at the moment the player joins the game, and checks to see whether or not their character is already loaded. If it is, it passes it into the modifyTransparency function. Regardless of that, it attaches a CharacterAdded event listener to the modifyTransparency function, such that whenever the player that we're currently dealing with respawns at any moment, that will be accounted for.
The event listener below the for loop accounts for players joining the game after the client has, as well as when they respawn. I've tested this, and it works just fine.
And if you want a technical explanation as to why my original code didn't quite work, here it is:
I think the technical issue was that the object passed into the modifyTransparency function was initially acquired by the script by attaching a ChildAdded event listener to Workspace. I don't think that the ChildAdded event was particularly designated for getting a player's character whenever they spawned. As far as I can tell, the ChildAdded event returns the instance that was added to the Workspace, even if its descendants haven't yet loaded. The CharacterAdded event of the player instance ensures that the character of the specified player has fully loaded, I would surmise, as when I switched to using the CharacterAdded event, it worked perfectly. So, when using the GetPlayerFromCharacter function in my original code, I ended up using a not fully-loaded character to determine the corresponding player who owned it. My guess is that the GetPlayerFromCharacter function iterates through every Player whose character has already loaded, and checks to see if the object passed in matches the character. When I called the function, I passed in the not fully-loaded character and the function compared that to all of the players whose character had already fully-loaded and determined that no player's character matched the one I passed in. This isn't even a technical issue, either, it's just a matter of not using the function that is designated for ensuring a player's character has loaded.
4 comments
This time nothing happened.. The script performance did show that the script was running though. If you can't seem to figure this out or if it's just gonna cause too much brain ache then please don't worry about this. If you're done just please leave this answer up because your explanation of some aspects in the script are very helpful to me.
Are you sure it's not working? Make sure that it's in a LocalScript inside of StarterPlayer, and that you copied the code character for character. It worked perfectly for me.
Oh! I meant to put it inside of StarterPlayerScripts inside of StarterPlayer. That's the issue.
Also, copy the code again as I realized I left something out.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Do not delete and then make duplicate questions.