Clothing scripting support

So I found this jacket on the roblox catalog and I was wondering how I could change the player’s clothes to be this suit. Also does the player have to own this jacket in order to have it even work?

3 Likes

Do you want all players in your game to have the black suit?

1 Like

Only the leader which ik how to code that but idk how to set their clothing to this suit

1 Like

Is your leader part of team script?

1 Like

Its a custom script

extra text 123

1 Like

I have this team model that changes in each with the apply humanoid description. You can play around with the Team scripts to fit your needs.

Or you can try this code below. You can change the asset IDs to match your needs.

local Players = game:GetService("Players")

-- Function to apply humanoid description to a specific character
local function applyHumanoidDescription(character)
    local humanoid = character:FindFirstChildWhichIsA("Humanoid")
    if humanoid then
        -- Create a HumanoidDescription
        local humanoidDescription = Instance.new("HumanoidDescription")

        -- Set properties for the HumanoidDescription
        humanoidDescription.HatAccessory = "rbxassetid://14012017490"
        humanoidDescription.FaceAccessory = "rbxassetid://14930757590" -- Replace with your Face Accessory ID
        humanoidDescription.BackAccessory = "rbxassetid://17438082263"
        humanoidDescription.BodyTypeScale = 1  -- Valid range is 0 to 1
        humanoidDescription.Face = "rbxassetid://86487700"
        humanoidDescription.GraphicTShirt = "rbxassetid://17578965036"
        humanoidDescription.Pants = "rbxassetid://12401613305"
        
        -- Apply the description immediately
        humanoid:ApplyDescription(humanoidDescription)
        
        -- Adjust the color of the head separately
        local head = character:FindFirstChild("Head")
        if head then
            head.BrickColor = BrickColor.new(Color3.new(0, 1, 0))
        end
    end
end

-- Function to handle player character
local function handleCharacter(character)
    if character.Name == "leader" then
        applyHumanoidDescription(character)
    end
end

-- Connect CharacterAdded event for each player
local function onPlayerAdded(player)
    player.CharacterAdded:Connect(function(character)
        handleCharacter(character)
    end)
    -- Apply to existing character if present
    if player.Character and player.Character.Name == "leader" then
        handleCharacter(player.Character)
    end
end

-- Connect for all current players
for _, player in ipairs(Players:GetPlayers()) do
    onPlayerAdded(player)
end

-- Connect for future players
Players.PlayerAdded:Connect(onPlayerAdded)
1 Like

The problem is the suit is labaled as a jacket not pants or shirt on the catalog

1 Like

U can use the apply humanoid description to get the jacket. Put the jacket asset id in the back accessory string. I just tried and it worked. I was able to wear a jacket from the market place.

1 Like

Do I have to remove the other ids?

1 Like

sure, if you do not need them. I removed the other ids.

local Players = game:GetService("Players")

-- Function to apply humanoid description to a specific character
local function applyHumanoidDescription(character)
    local humanoid = character:FindFirstChildWhichIsA("Humanoid")
    if humanoid then
        -- Create a HumanoidDescription
        local humanoidDescription = Instance.new("HumanoidDescription")

        -- Set properties for the HumanoidDescription
        humanoidDescription.BackAccessory = "rbxassetid://17438082263"  -- Replace with your Jacket assest ID
        
        -- Apply the description immediately
        humanoid:ApplyDescription(humanoidDescription)
    else
        warn("Humanoid not found in character:", character.Name)
    end
end

-- Function to handle player character
local function handleCharacter(character)
    if character.Name == "leader" then
        applyHumanoidDescription(character)
    end
end

-- Connect CharacterAdded event for each player
local function onPlayerAdded(player)
    player.CharacterAdded:Connect(function(character)
        handleCharacter(character)
    end)
    -- Apply to existing character if present
    if player.Character and player.Character.Name == "leader" then
        handleCharacter(player.Character)
    end
end

-- Connect for all current players
for _, player in ipairs(Players:GetPlayers()) do
    onPlayerAdded(player)
end

-- Connect for future players
Players.PlayerAdded:Connect(onPlayerAdded)
2 Likes

Watch this video, I have your suit on.
robloxapp-20240913-2122239.wmv (2.1 MB)

2 Likes

How is it even possible for a jacket type clothing to be put on the back accessory id

1 Like

Because you place a jacket on your back. Watch my video it works as a back accessory.

1 Like

Ok so I tried a different approach but it doesnt work.

local DaysInYr = 365

local CurrentLeaderSeniority

local function GetTopSeniority()

	local TopSeniority

	for _, plr in pairs(game.Players:GetPlayers()) do

		local PlrSeniority = plr.AccountAge / DaysInYr

		if not TopSeniority or PlrSeniority > TopSeniority then

			TopSeniority = PlrSeniority

		end

	end

	return TopSeniority

end

local RS = game:GetService("ReplicatedStorage")

local NotifyPlr = RS:WaitForChild("RemoteEvents"):WaitForChild("NotifyPlr")

local SendChatMessage = RS:WaitForChild("RemoteEvents"):WaitForChild("SendChatMessage")

local LeaderCrown = RS:WaitForChild("Leader's Crown")

local LeaderHL = RS:WaitForChild("LeaderHL")

local TS = game:GetService("TweenService")

local TweenStyle = TweenInfo.new(1.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)

local LeaderClothesIds = {
	["Shirt"] = 47740175;
	["Pants"] = 138981719;
};

local function IsLeader(UserId)
	
	local plr = game.Players:FindFirstChild(game.Players:GetPlayerByUserId(UserId).Name)
	
	if plr then
		
		if plr:WaitForChild("IsLeader").Value == true then
			
			return true
			
		else
			
			return false
			
		end
		
	end
	
end

local function ChooseLeader()
	
	local TopSeniority = GetTopSeniority()
	
	for _, plr in pairs(game.Players:GetPlayers()) do
		
		local PlrSeniority = plr.AccountAge / DaysInYr
		
		if PlrSeniority >= TopSeniority and not IsLeader(plr.UserId) then
			
			plr:WaitForChild("IsLeader").Value = true
			
			local Char = plr.Character
			
			if Char then
				
				Char.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=47740175"
				
				Char.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=138981719"
				
				local ClonedLeaderHL = LeaderHL:Clone()
				ClonedLeaderHL.Parent = Char
				
				TS:Create(Char.Humanoid.BodyDepthScale,TweenStyle,{Value = 1.75}):Play()

				TS:Create(Char.Humanoid.BodyHeightScale,TweenStyle,{Value = 1.75}):Play()

				TS:Create(Char.Humanoid.BodyWidthScale,TweenStyle,{Value = 1.75}):Play()

				TS:Create(Char.Humanoid.HeadScale,TweenStyle,{Value = 1.75}):Play()

				Char.Humanoid.WalkSpeed = 26
				
				NotifyPlr:FireClient(plr,"Selected Leader")

				task.delay(2,function()

					SendChatMessage:FireAllClients([[<font size="18"><font color="rgb(243, 206, 57)"><font family="rbxasset://fonts/families/BuilderSans.json"><font weight="Medium">[Server]: @]] .. plr.Name .. [[ has been selected as the Sr. Leader!</font></font></font></font>]])

					--SendChatMessage:FireAllClients([[<font size="19"><font color="rgb(243, 206, 57)"><font family="rbxasset://fonts/families/Cairo.json"><font weight="SemiBold">[Server]: @]] .. shared.CurrentLeader.Name .. [[ has been selected as the Sr. Leader!</font></font></font></font>]])

				end)
				
			end
			
			break
			
		end
		
	end
	
	--[[
	
	local ClonedLeaderCrown = LeaderCrown:Clone()
	ClonedLeaderCrown.Parent = shared.CurrentLeader.Character.Head

	ClonedLeaderCrown.CFrame = CFrame.new(shared.CurrentLeader.Character.Head.Position + Vector3.new(0,3.5,0))

	local WC = Instance.new("WeldConstraint")
	WC.Part0 = ClonedLeaderCrown
	WC.Part1 = shared.CurrentLeader.Character.Head
	WC.Parent = ClonedLeaderCrown
	
	--]]
	
end

game.Players.PlayerAdded:Connect(function(plr)
	
	local TopSeniority = GetTopSeniority()
	
	task.wait(5)
	
	print("outfit")
	
	ChooseLeader()
	
	--if CurrentLeaderChar then CurrentLeaderChar.Head:FindFirstChild("Leader's Crown"):Destroy() end
	
	plr.CharacterAdded:Connect(function(Char)
		
		

	end)
	
end)

game.Players.PlayerRemoving:Connect(function(plr)
	
	local LeaderInGame = game.Players:FindFirstChild(shared.CurrentLeader.Name)
	
	if not LeaderInGame then
		
		ChooseLeader()
		
	end
	
end)
1 Like

Good luck! Everything worked fine with the script I gave you.

1 Like

Fair enough thank you for the help though.

1 Like