Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

PlayerAdded event not firing?

Asked by 4 years ago

Hey guys, so here I come again with my hide-other-players script. It's in this current form:


game.Players.PlayerAdded:Connect(function(plrVar) for _,player in pairs(game.Players:GetPlayers()) do --if player.UserId == plr.UserId then return end player.CharacterAppearanceLoaded:Connect(function(char) for _,cPart in pairs(char:GetDescendants()) do if cPart:IsA('Part') or cPart:IsA('BasePart') or cPart:IsA('MeshPart') then cPart.Transparency = 1 end end if char:WaitForChild('ForceField') then char.ForceField.Visible = false end char.Head.face.Transparency = 1 char.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None end) end end)

It's a long one, but all it should do is when an player joins, hide its character to me. Yes, it's in LocalScript for these purposes. But once I've wrapped the for loop into the PlayerAdded event, it's not running at all

Thanks in advance.

0
or you can maintain transparency on the server and change transparency on the client which is much easier but ok Fifkee 2017 — 4y
0
What? I want to hide the players only locally but idrg what you mean Doge_Brigade 94 — 4y

1 answer

Log in to vote
0
Answered by
sheepposu 561 Moderation Voter
4 years ago

Solution 1. LocalScript indside the StarterGui -

local plr = game.Players.LocalPlayer

repeat wait() until plr.Character

local char = plr.Character
for _,cPart in pairs(char:GetDescendants()) do
    if cPart:IsA('Part') or cPart:IsA('BasePart') or cPart:IsA('MeshPart') then cPart.Transparency = 1 end  
end     
if char:WaitForChild('ForceField') then char.ForceField.Visible = false end
char.Head.face.Transparency = 1
char.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None

Solution 2. Script in ServerScriptService -

game.Players.PlayerAdded:Connect(function(plr)
    repeat wait() until plr.Character

    local char = plr.Character

    for _,cPart in pairs(char:GetDescendants()) do
        if cPart:IsA('Part') or cPart:IsA('BasePart') or cPart:IsA('MeshPart') then cPart.Transparency = 1 end  
    end     
    if char:WaitForChild('ForceField') then char.ForceField.Visible = false end
    char.Head.face.Transparency = 1
    char.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end)

Hope this works

0
Why does it need to be in StarterGui? I have it in StarterPlayerScripts Doge_Brigade 94 — 4y
0
That works too sheepposu 561 — 4y
0
That's the problem - it doesn't. Doge_Brigade 94 — 4y
0
hmmm... did you try the ServerScriptService script sheepposu 561 — 4y
0
You may also need to try GetChildren() rather than GetDescendants() sheepposu 561 — 4y
Ad

Answer this question