Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

Spelled Appearance wrong. I edited my answer.

1 answer

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!

5 comments

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.

0

LOL

0

I edited my answer. Should work now.

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.

0

I agree

This discussion is preserved as it was. New answers, comments, and votes are closed.