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

Why is this script not removing the players face when they join?

Asked by
Hexcede 52
10 years ago

When the players joins it should remove their face. But it does nothing. This script is in the workspace.

1function playerJoined(plr)
2    local char = plr.Character
3    local head = char.Head
4    local face = head:WaitForChild("face")
5    face:remove()
6end
7 
8game.Players.ChildAdded:connect(playerJoined)

2 answers

Log in to vote
1
Answered by
iLegitus 130
10 years ago

Try this:

(First of all this is a localscript inside starterpack)

1Player = game.Players.LocalPlayer
2 
3wait(1.4)
4if Player.Character.Head:FindFirstChild("face") then
5Player.Character.Head.face:remove()
6else
7print("Face remover script broken.")
8end
0
I had to change :FindFirstChild to :WaitForChild and that fixed it! Hexcede 52 — 10y
0
Np. iLegitus 130 — 10y
0
Just a tip: this method doesn't work with FilteringEnabled adark 5487 — 10y
Ad
Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

The Player arrives before the Character.

What this means is that you have to wait for the Character to show up before you can access any part of it:

EDIT: I just did some testing, and it looks like the code does remove the initial face, but not one that loads when the CharacterAppearance loads. This code should fix that:

01function playerJoined(plr)
02    plr.CharacterAdded:connect(function(char)
03        wait()
04        local head = char.Head
05        head:WaitForChild("face"):Destroy()
06        char.ChildAdded:connect(function()
07            if head:FindFirstChild("face") then
08                head.face:Destroy()
09            end
10        end)
11    end)
12end
13 
14game.Players.ChildAdded:connect(playerJoined)
0
Its not working :o I thought that it would! Hexcede 52 — 10y
0
You are missing an ) at the end of the first end but even if I fix that it doesn't work at all Hexcede 52 — 10y
0
Are you getting any output? adark 5487 — 10y
0
I am not getting any output. It's in the workspace too by the way. Hexcede 52 — 10y
0
And its a normal script non-local Hexcede 52 — 10y

Answer this question