Locker room
A fully scripted locker room for every team. Players browse their team's uniforms and equipment on a live 3D preview of their own character, apply their rank epaulettes, and save outfits as presets to change into with a single click.
4 code excerpts below
local function applyOutfit(player)
local character = player.Character
if not character then
return 0
end
local outfit = outfitFor(player)
local skipped = 0
for _, category in ipairs(Config.Categories) do
if category.Multiple then
local want = type(outfit[category.Id]) == "table" and outfit[category.Id] or {}
local wearing = {}
for _, inst in ipairs(character:GetChildren()) do
if inst:GetAttribute("LockerCategory") == category.Id and inst:GetAttribute("LockerId") then
wearing[inst:GetAttribute("LockerId")] = inst
end
end
for id in pairs(want) do
local item = Config.ById[id]
if not (item and item.Category == category.Id and Config.Allowed(item, player.Team)) then
want[id] = nil
skipped += 1
elseif not wearing[id] then
if not putOn(player, character, item) then
want[id] = nil
end
end
end
for id, inst in pairs(wearing) do
if not want[id] then
inst:Destroy()
end
end
if next(want) then
outfit[category.Id] = want
else
outfit[category.Id] = nil
restoreHeld(player, character, category.Id)
end
continue
end
local id = outfit[category.Id]
local item = id and Config.ById[id]
local wearing = nil
for _, inst in ipairs(character:GetChildren()) do
if inst:GetAttribute("LockerCategory") == category.Id then
wearing = inst:GetAttribute("LockerId")
end
end
if item and Config.Allowed(item, player.Team) and item.Category == category.Id then
if wearing ~= item.Id then
if not putOn(player, character, item) then
outfit[category.Id] = nil
end
end
else
if item then
skipped += 1
end
outfit[category.Id] = nil
if wearing then
takeOff(player, character, category.Id)
end
end
end
return skipped



