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
9 years ago

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

function playerJoined(plr)
    local char = plr.Character
    local head = char.Head
    local face = head:WaitForChild("face")
    face:remove()
end

game.Players.ChildAdded:connect(playerJoined)

2 answers

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

Try this:

(First of all this is a localscript inside starterpack)

Player = game.Players.LocalPlayer

wait(1.4)
if Player.Character.Head:FindFirstChild("face") then
Player.Character.Head.face:remove()
else
print("Face remover script broken.")
end

0
I had to change :FindFirstChild to :WaitForChild and that fixed it! Hexcede 52 — 9y
0
Np. iLegitus 130 — 9y
0
Just a tip: this method doesn't work with FilteringEnabled adark 5487 — 9y
Ad
Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 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:

function playerJoined(plr)
    plr.CharacterAdded:connect(function(char)
        wait()
        local head = char.Head
        head:WaitForChild("face"):Destroy()
        char.ChildAdded:connect(function()
            if head:FindFirstChild("face") then
                head.face:Destroy()
            end
        end)
    end)
end

game.Players.ChildAdded:connect(playerJoined)

0
Its not working :o I thought that it would! Hexcede 52 — 9y
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 — 9y
0
Are you getting any output? adark 5487 — 9y
0
I am not getting any output. It's in the workspace too by the way. Hexcede 52 — 9y
0
And its a normal script non-local Hexcede 52 — 9y

Answer this question