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

Changing Clothing at the start of the game?

I need to know how to make a script that changes the persons normal clothing into the clothing like gladiator armor on them?

1 answer

✓ Accepted answer

If you want to do this the easiest thing to do is to use the PlayerAdded event.

game.Players.PlayerAdded:connect(function(player) 

Next, check to see if the player has a shirt or pants

game.Players.PlayerAdded:connect(function(player)
	if player:FindFirstChild("Shirt") then
		player:FindFirstChild("Shirt").ShirtTemplate = "[insert shirt asset here]"
	end
	if player:FindFirstChild("Pants") then
		player:FindFirstChild("Pants").PantsTemplate = "[insert pants asset here]"
end

The if statements will only execute if the player is wearing a shirt for the first, and pants for the second.

The next step would be to insert new shirt and pants objects if they do not have a shirt or pants, or if they do to set their shirt and pants' asset IDs to that of the clothing you wish to have the player wear.

The final script, then will look like this

game.Players.PlayerAdded:connect(function(player)
	if player:FindFirstChild("Shirt") then
		player:FindFirstChild("Shirt").ShirtTemplate = "[insert shirt asset here]"
	else
		local shirt = Instance.new("Shirt")
		shirt.ShirtTemplate = "[insert shirt asset here]"
		shirt.Parent = player
	end
	if player:FindFirstChild("Pants") then
		player:FindFirstChild("Pants").PantsTemplate = "[insert pants asset here]"
	else
		local pants = Instance.new("Pants")
		pants.PantsTemplate = "[insert pants asset here]"
		pants.Parent = player
	end
end

Hope this helps!

4 comments

0

Thanks man that helps alot

0

it doesn't seem to be working

0

@CaptainRoblox281, what error are you getting?

0

Been trying to figure this one out for a while. Thanks for the help Klamman!

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