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

Should the clothing script be local?

Should this be a local script?

local shirt = Instance.new("Shirt")
local pants = Instance.new("Pants")
local shirtID="http://www.roblox.com/asset/?id=213381222"
local pantsID = "http://www.roblox.com/asset/?id=105220573"

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        player.CanLoadCharacterAppearance=false

        shirt.ShirtTemplate=shirtID
        shirt.Parent=player.Character

        pants.PantsTemplate=pantsID
        pants.Parent=player.Character
    end)
end)

2 answers

✓ Accepted answer

This script should not be a LocalScript as PlayerAdded only works in a server script. However, you need to make sure CanLoadCharacterAppearance is false before the character spawns in, otherwise the character's usual appearance will still load as soon as they spawn.


Code:

local shirt = Instance.new("Shirt")
local pants = Instance.new("Pants")
local shirtID="http://www.roblox.com/asset/?id=213381222"
local pantsID = "http://www.roblox.com/asset/?id=105220573"

game.Players.PlayerAdded:connect(function(player)
	player.CanLoadCharacterAppearance=false
	player.CharacterAdded:connect(function(character)
		shirt.ShirtTemplate=shirtID
		shirt.Parent=character --Using the character variable since it's there.

		pants.PantsTemplate=pantsID
		pants.Parent=character --Using the character variable since it's there.
	end)
end)

I hope my answer helped you. If it did, be sure to accept it.

No, it shouldn't be a localscript. Localscripts can only be placed in certain places. Workspace is not one of them. If this is in a script, it should work fine.

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