Hey everybody.
I am working on a character customization system for my roleplay game. First things first - I decided to tackle shirts and pants as I thought it’d be simple.
Lord almighty, it isn’t.
-- // Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
-- // Variables
local Main = script.Parent :: Frame
local Viewport = Main.Viewport :: ViewportFrame
local Dummy = Viewport:WaitForChild("Dummy") :: Model
local shirt = Dummy:FindFirstChildOfClass("Shirt")
local pants = Dummy:FindFirstChildOfClass("Pants")
-- // Accessories
local AccessoriesFolder = ReplicatedStorage:WaitForChild("Accessories") :: Folder
local ClothingModule = require(AccessoriesFolder:FindFirstChild("Clothing"))
local choices = {}
-- // Code
-- // Checks
if not ClothingModule then
warn("Could not get clothing module!")
end
----
function getClothing(category: string) : {string}
if ClothingModule[category] then
return ClothingModule[category]
end
return {}
end
function getItems(category: string) : {Instance}
local folder = AccessoriesFolder:FindFirstChild(category)
if folder then
return folder:GetChildren()
end
return {}
end
function getItemList(category: string) : {any}
if category == "Shirt" or category == "Pants" then
return getClothing(category)
else
return getItems(category)
end
end
function updatePreview(category: string)
local items = getItemList(category)
if #items == 0 then return warn("List of items is empty!") end
local selectedIndex = choices[category]
if not selectedIndex then return warn("Invalid selection index!") end
local selected = items[selectedIndex]
if not selected then return warn("Could not get selected item in Character Customizer!") end
if category == "Shirt" then
if not shirt then
shirt = Instance.new("Shirt")
shirt.Parent = Dummy
end
local id = ClothingModule.Shirt[selectedIndex]
if shirt and id then
shirt.ShirtTemplate = id
end
return
elseif category == "Pants" then
if not pants then
pants = Instance.new("Pants")
pants.Parent = Dummy
end
local id = ClothingModule.Pants[selectedIndex]
if pants and id then
pants.PantsTemplate = id
end
return
end
for _, accessory in Dummy:GetChildren() do
if accessory:IsA("Accessory") and accessory:GetAttribute("Category") == category then
accessory:Destroy()
end
end
local newAccessory = selected
if newAccessory then
local clone = newAccessory:Clone()
clone.Parent = Dummy
end
end
for _, frame in pairs(Main:GetDescendants()) do
if frame:IsA("Frame") and frame:GetAttribute("Category") then
local category = frame:GetAttribute("Category") :: string
choices[category] = 1
frame.Back.MouseButton1Click:Connect(function()
local items = getItemList(category)
choices[category] -= 1
if choices[category] < 1 then
choices[category] = #items
end
updatePreview(category)
end)
frame.Forward.MouseButton1Click:Connect(function()
local items = getItemList(category)
choices[category] += 1
if choices[category] > #items then
choices[category] = 1
end
updatePreview(category)
end)
end
end
Here’s the funny thing - the IDs are getting gotten. The dummy exists, every single required variable exists. But when I try changing the ID - it remains blank. WHY?!
The dummy is in a viewport.
I literally have no idea how to stop this, I tried both the full URL and rbxassetid, literally NOTHING works!! I am wasting my time and sanity just for this dumb thing to work.
If you’re curious, here’s my module.
return {
Shirt = {
"rbxassetid://6067501477",
"rbxassetid://4996763405",
},
Pants = {
"rbxassetid://6067504287",
"rbxassetid://7581780596"
}
}


