Script wont apply clothes, the player instead is naked even if it prints out that the clothes were applied
-- Team IDs and corresponding template IDs
local teamsAndClothes = {
NEUTRAL = {default = true}, -- Default clothes
VOLBLOX = {shirt = 16931237552, pants = 16930928710},
WATEROUS = {shirt = 17263115715, pants = 17263118315}
}
-- Function to assign clothing based on player's team
local function assignClothing(player)
local function onCharacterAdded(character)
-- Wait for the Humanoid to be present in the character
local humanoid = character:WaitForChild("Humanoid")
-- Give some time for the character to fully load
wait(1)
-- Get player's team
local teamName = "NEUTRAL" -- Default to NEUTRAL if player has no team
local team = player.Team
if team then
teamName = team.Name
end
print(player.Name .. " is in team: " .. teamName)
-- Check and assign clothing based on team
local clothes = teamsAndClothes[teamName]
if clothes then
if clothes.default then
-- Remove any existing clothing
local shirt = character:FindFirstChild("Shirt")
local pants = character:FindFirstChild("Pants")
if shirt then shirt:Destroy() end
if pants then pants:Destroy() end
else
-- Apply specified clothing
local shirt = character:FindFirstChild("Shirt") or Instance.new("Shirt")
local pants = character:FindFirstChild("Pants") or Instance.new("Pants")
shirt.Name = "Shirt"
pants.Name = "Pants"
-- Clear any existing template
shirt.ShirtTemplate = ""
pants.PantsTemplate = ""
-- Set new templates using template IDs
shirt.ShirtTemplate = "rbxassetid://" .. clothes.shirt
pants.PantsTemplate = "rbxassetid://" .. clothes.pants
-- Parent clothing to character
shirt.Parent = character
pants.Parent = character
print("Applied clothing to " .. player.Name .. ": ShirtTemplate=" .. shirt.ShirtTemplate .. ", PantsTemplate=" .. pants.PantsTemplate)
end
end
end
-- Connect to CharacterAdded event
player.CharacterAdded:Connect(onCharacterAdded)
-- Handle the case where the character already exists
if player.Character then
onCharacterAdded(player.Character)
end
end
-- Player added event
game.Players.PlayerAdded:Connect(assignClothing)
-- For handling already connected players when the script runs
for _, player in ipairs(game.Players:GetPlayers()) do
assignClothing(player)
end