Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Should the clothing script be local?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

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

Log in to vote
1
Answered by 9 years ago

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.

Ad
Log in to vote
1
Answered by 9 years ago

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.

Answer this question