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

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

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

1 comment

0

Where's the attempted code? Also, you'll need a set of assetids.

1 answer

✓ Accepted answer

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...

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