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

How to make a certain player wear shirts, pants and change face?

I am new to scripting and have tried multiple ways to change a certain player's avatar. In order to get this to work I tried doing this:


local playername = game.Players.LocalPlayer.Name
local player = workspace:FindFirstChild(""..playername.."")
if player ~= nil then
  player:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=0000000" 
  player:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=0000000"
end
end)

Not sure if this is the right way to do it but please revise my code if needed thanks!

1 answer

local playername = game.Players.LocalPlayer.Name
local player = workspace:FindFirstChild(playername) 
player:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=0000000" 
player:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=0000000"

1.workspace:FindFirstChild(""..playername.."") doesn't make sense because playername is already a string 2.if player ~= nil then is useless 3. At the line 7 end) is useless too because you don't have a function. Example:

part.Touched:Connect(function()
	print("hey")
end)

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