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

How do I make people get random shirts, pants, hats, etc when joining the game?

Asked by 10 years ago

In my game people are going to wear masks and fancy clothing. So I need help doing that. Thank you!

0
Where's the attempted code? Also, you'll need a set of assetids. Lacryma 548 — 10y

1 answer

Log in to vote
2
Answered by
RM0d 305 Moderation Voter
10 years ago

put this in a local script in the startergui

assets={}
    assets.Shirt{159163630,159163633,159163637} --Shirts
    assets.Pants{65160698,98355680} 
    assets.Hats= game.Lighting.Hats:GetChildren() -- hats go in a model under lighting called Hats

player =  game.Players.LocalPlayer -- gets the player
a = player .Character:GetChildren() -- Gets parts used for cleaning

function Clear() -- Removes hats Character meshes shirts and pants also T-shirts
for xX = 1,#a do
    if a[xX].ClassName=="Hat" or a[xX].ClassName=="CharacterMesh" or a[xX].ClassName=="Shirt" or  a[xX].ClassName=="Pants" or a[xX].ClassName=="ShirtGraphic" then
        a[xX]:Destroy()

    elseif a[xX].ClassName=="Part" and a[xX].Name~="HumanoidRootPart" then a[xX].Transparency = 0 
     end
    end
  end

Clear() -- Cleans the player
wait()
Shirt = Instance.new("Shirt",player.Character)
pants = Instance.new("Pants",player.Character) pants.Name = "Pants"
hat = assets.Hats[math.random(1,#assets.Hats)]:Clone()
Shirt.ShirtTemplate = "rbxassetid://" .. assets.Shirt[math.random(1,#assets.Shirt)]
pants.PantsTemplate = "rbxassetid://" .. assets.Pants[math.random(1,#assets.Pants)]
hat.Parent = player.Character 

What happens...

  1. Get Objects of player

  2. if shirt or pants or mesh .etc, Destroy() it

  3. Then Clone hat into player.

  4. Create new instance of pants and shirt. and pops into player

  5. give them a texture

6.Done

If i helped Upvote please. If you have any problems comment below...

Ad

Answer this question