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

How to make a script that will make a player wear a uniform?

I need a script that will actually make a player wear a uniform depending on his rank in a specific group, and wear an helmet depending the group. I actually have, in the serverStorage, a folder "Uniform" and inside it theres the folder 'clothes' that actually contain all the clothes of the different legion/rank inside this legion (As 104thHrPants / 104thHrShirt / 104thPants / 104thShirt) and a folder "Helmet" (104thHrHelmet / 104thHelmet) <-- each of them have their specific clothe ID. Hr Rank start at '100'

RegShirt = game.ServerStorage.Uniform.Clothes.RegShirt
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        if plr:GetRankInGroup(2772068) > 100 then
            player.ClearCharacterAppearance()

            player.LoadCharacterAppearance(RegShirt) 
        end
    end)
end)

In a past request someone has gave me this script, but it doesnt make the player wear the shirt/pants over and doesnt make the player wear the Helmet (The helmet is not in the catalog)

2 comments

0

What value does the word Item hold in LoadCharacterAppearance?

0

Well, I should have put "RegShirt = game.ServerStorage.Uniform.Clothes.RegShirt" and the item would be replaced by; RegShirt

2 answers

This is one, rather than wasting storage by putting shirts and pants there. For hats, I can't help you:

local shirtid = 0 --Add the ID of the shirt here
local pantsid = 00 --Add the ID of the pants here

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(chr)
		if plr:GetRankInGroup(2772068) > 100 then
			local shirt = chr:FindFirstChild("Shirt")
			if shirt then
				shirt.ShirtTemplate = "rbxassetid://" ..shirtid
			else
				local nshirt = Instance.new("Shirt", chr)
				nshirt.Name = "Shirt"
				nshirt.ShirtTemplate = "rbxassetid://" ..shirtid
			end
			local pants = chr:FindFirstChild("Pants")
			if pants then
				pants.PantsTemplate = "rbxassetid://" ..pantsid
			else
				local npants = Instance.new("Pants, chr")
				npants.Name = "Pants"
				npants.PantsTemplate = "rbxassetid://" ..pantsid
			end
			--If you want to remove T-Shirts, then leave this code. If not, then erase that
			local tee = chr:FindFirstChild("ShirtGraphic")
			if tee then
				tee:Destroy()
			end
		end
	end)
end)

1 comment

0

Thanks but I got like over 20 pants/shirt, I think make that would take too long. (the Shirtid = 00)

Here is a revised answer. Adjust this to match your needs

-- @author itsJooJoo
-- @author Narrev

local ShirtId = 0
local PantsId = 0
local RemoveTShirts = true
local RemoveHats = true

local Hat = script:FindFirstChild("Hat") -- Put directory of hat here

game:GetService("Players").PlayerAdded:connect(function(Player)
	-- Run each a time a player joins
	Player.CharacterAdded:connect(function(Character)
		-- Run each time a player spawns
		if Player:GetRankInGroup(2772068) > 99 then
			local Shirt = Character:FindFirstChild("Shirt") or Instance.new("Shirt", Character)
			Shirt.Name = "Shirt"
			Shirt.ShirtTemplate = "rbxassetid://" ..ShirtId

			local Pants = Character:FindFirstChild("Pants") or Instance.new("Pants, Character")
			Pants.Name = "Pants"
			Pants.PantsTemplate = "rbxassetid://" ..PantsId
			
			if RemoveTShirts then
				local T_Shirt = Character:FindFirstChild("ShirtGraphic")
				if T_Shirt then
					T_Shirt:Destroy()
				end
			end

			if RemoveHats then
				for _, Object in next, Character:GetChildren() do
					if Object:IsA("Hat") then
						Object:Destroy()
					end
				end
			end

			if Hat then
				local Hat = Instance.new("Part")
				Hat.BottomSurface = "Smooth";
				Hat.TopSurface = "Smooth";
				Hat.Size = Hat.Size;
				Hat.Name = "Hat";

				local Mesh = Instance.new("SpecialMesh", Hat)
				Mesh.MeshType = "FileMesh";
				Mesh.MeshId = robloxAsset .. Hat.MeshId;
				Mesh.Scale = Hat.Scale;
				Mesh.TextureId = robloxAsset .. Hat.TextureId;
				
				local Weld = Instance.new("Weld", Hat)
				Weld.Name = "HatWeld";
				Weld.Parent = ;
				Weld.Part0 = Character.Head;
				Weld.Part1 = Hat;
				Weld.C0 = CFrame.new(0, .5, 0);
				C1 = Hat.AttachmentPoint or CFrame.new(0, 0.3, 0.05);
				
				Hat.Parent = Character
			end
		end
	end)
end)

1 comment

0

Here again thanks but it would take too much "shirtID = 0" and "pantsId = 0".

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