This is a script I composed to change any character that joins the game's clothing:
1 | plr.CharacterAdded:connect( function (char) |
2 | player.Pants.PantsTemplate = 182807730 |
3 | player.Shirt.ShirtTemplate = 182807618 |
4 | end ) |
Basically, when I try to run this, my character's clothing flashes grey (loading the texture I assume) then going to what my character is set to look like. (Not what the PantsTemplate / ShirtTemplate is set to in the script) What am I doing wrong
This isn't anywhere near a full script.
How do you get plr
? Where is it defined? It isn't. Along with that, the Pants
and Shirt
are in the character, not the player
, which again you don't define.
To get the player I suggest the PlayerAdded
function.
1 | -- Regular Script in ServerScriptService |
2 | --// Services |
3 | local Players = game:GetService( "Players" ) |
4 |
5 | --\\ Code |
6 | Players.PlayerAdded:Connect( function (plr) |
7 |
8 | end ) |
Cool! Now we have the player; let's get the character. We can get the character with the CharacterAdded
event.
01 | -- Regular Script in ServerScriptService |
02 | --// Services |
03 | local Players = game:GetService( "Players" ) |
04 |
05 | --\\ Code |
06 | Players.PlayerAdded:Connect( function (plr) |
07 | plr.CharacterAdded:Connect( function (char) |
08 |
09 | end ) |
10 | end ) |
Now we should be able to add your code:
01 | -- Regular Script in ServerScriptService |
02 | --// Services |
03 | local Players = game:GetService( "Players" ) |
04 |
05 | --\\ Code |
06 | Players.PlayerAdded:Connect( function (plr) |
07 | plr.CharacterAdded:Connect( function (char) |
08 | char:WaitForChild( "Pants" ).PantsTemplate = 182807731 |
09 | char:WaitForChild( "Shirt" ).ShirtTemplate = 182807619 |
10 | end ) |
11 | end ) |