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

I tried to make a certain face decal for every player who joins my game and it did not work, why?

Asked by 7 years ago

This is the script i used but did not work...

  1. game.workspace.ChildAdded:connect(function(plr)
  2. local name = plr.Name
  3. local playerinplayers = game.Players:FindFirstChild(plr.Name)
  4. if playerinplayers ~= nil then
  5. playerinplayers.CanLoadCharacterApperence = false
  6. plr.Head.face.Texture = "rbxassetid//156071939"
  7. end
0
Spelled Appearance wrong. I edited my answer. User#11440 120 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

You need Parentheses to close the anonymous function.

Also, Why did you go through the process of finding the player in players when the PlayerAdded function gives you the player from the start?

I'm going to be using the Players service because it would make the code much more simple.

Your fixed, and simplified, code should look like this,

game.Players.PlayerAdded:connect(function(plr)
    plr.CanLoadCharacterApperence = false
    plr.Head.face.Texture = "rbxassetid//156071939"
end)-- Added Parentheses

Head is a child of the character, not the player.

To get the character, I'm going to use the CharacterAdded Function. I'm also going to use WaitForChild because it's cool to do that.

game.Players.PlayerAdded:connect(function(plr)
    plr.CanLoadCharacterApperence = false
    plr.CharacterAdded:connect(function(char)
        char:WaitForChild("Head"):WaitForChild("face").Texture = "rbxassetid//156071939"
    end)
end)

You spelled Appearance wrong.

Final Script,

game.Players.PlayerAdded:connect(function(plr)
    plr.CanLoadCharacterAppearance = false
    plr.CharacterAdded:connect(function(char)
        char:WaitForChild("Head"):WaitForChild("face").Texture = "rbxassetid//156071939"
    end)
end)

Side note,

You should really learn what error messages mean, and how to read them.

I hope I helped!

Good Luck!

If I did help, remember to accept my answer. Accepting answers gives us both reputation!
0
This did not work.. maybe i copied it wrong or something but it's alright for now because for the game i am making i dont need this i just wanted to know. lalexn12 5 — 7y
0
LOL User#11440 120 — 7y
0
I edited my answer. Should work now. User#11440 120 — 7y
0
Use game:GetService('Players').PlayerAdded:connect(function(player)) noob... Just because something got added to the Workspace does not mean that is the player's character. Im_Kritz 334 — 7y
0
I agree User#11440 120 — 7y
Ad

Answer this question