This is a script I composed to change any character that joins the game's clothing:
plr.CharacterAdded:connect(function(char) player.Pants.PantsTemplate = 182807730 player.Shirt.ShirtTemplate = 182807618 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.
-- Regular Script in ServerScriptService --// Services local Players = game:GetService("Players") --\\ Code Players.PlayerAdded:Connect(function(plr) end)
Cool! Now we have the player; let's get the character. We can get the character with the CharacterAdded
event.
-- Regular Script in ServerScriptService --// Services local Players = game:GetService("Players") --\\ Code Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) end) end)
Now we should be able to add your code:
-- Regular Script in ServerScriptService --// Services local Players = game:GetService("Players") --\\ Code Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) char:WaitForChild("Pants").PantsTemplate = 182807731 char:WaitForChild("Shirt").ShirtTemplate = 182807619 end) end)