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?
Do you want all players in your game to have the black suit?
Only the leader which ik how to code that but idk how to set their clothing to this suit
Is your leader part of team script?
Its a custom script
extra text 123
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)
The problem is the suit is labaled as a jacket not pants or shirt on the catalog
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.
Do I have to remove the other ids?
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)
How is it even possible for a jacket type clothing to be put on the back accessory id
Because you place a jacket on your back. Watch my video it works as a back accessory.
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)
Good luck! Everything worked fine with the script I gave you.
Fair enough thank you for the help though.