I can possibly send the important parts from both scripts, as it may contain useful stuff (?)
this is where the tryon is being fired and where the buttons are being created:
game:GetService("ReplicatedStorage").productList.OnClientEvent:Connect(function(model)
tryon = model
-- Reset the total cost and accessoryCosts when a new model is loaded
accessoryCosts = {}
local humanoid = model:WaitForChild("Humanoid")
local desc = humanoid.HumanoidDescription
local hats = string.split(desc.HatAccessory, ",")
local faceaccessory = string.split(desc.FaceAccessory, ",")
local waist = string.split(desc.WaistAccessory, ",")
local hair = string.split(desc.HairAccessory, ",")
local front = string.split(desc.FrontAccessory, ",")
local back = string.split(desc.BackAccessory, ",")
local neck = string.split(desc.NeckAccessory, ",")
local shoulders = string.split(desc.ShouldersAccessory, ",")
script.Parent.Items.ScrollingFrame.CanvasPosition = Vector2.new(0, 0)
-- Remove existing buttons
for _, v in ipairs(script.Parent.Items.ScrollingFrame:GetChildren()) do
if v:IsA("ImageButton") then
v:Destroy()
end
end
-- Create buttons for each accessory type
createButtons(hats, "hats")
createButtons(faceaccessory, "faceaccessory")
createButtons(waist, "waist")
createButtons(hair, "hair")
createButtons(front, "front")
createButtons(back, "back")
createButtons(neck, "neck")
createButtons(shoulders, "shoulders")
-- Create buttons for special accessories
if desc.Face and tonumber(desc.Face) and tonumber(desc.Face) > 0 then
createButton(desc.Face, "face")
end
if desc.Shirt and tonumber(desc.Shirt) and tonumber(desc.Shirt) > 0 then
createButton(desc.Shirt, "shirt")
end
if desc.Pants and tonumber(desc.Pants) and tonumber(desc.Pants) > 0 then
createButton(desc.Pants, "pants")
end
if desc.GraphicTShirt and tonumber(desc.GraphicTShirt) and tonumber(desc.GraphicTShirt) > 0 then
createButton(desc.GraphicTShirt, "tshirt")
end
sound:Play()
for _, v in ipairs(script.Parent.Items.ScrollingFrame:GetChildren()) do
if v:IsA("ImageButton") then
local buy = v.Frame.Buy
if buy and buy:IsA("TextButton") then
buy.Activated:Connect(function()
mps:PromptPurchase(player, v.Name)
end)
end
local try = v.Frame.Try
if try and try:IsA("TextButton") then
try.Activated:Connect(function()
local selectedHatID = v.Name
local selectedFaceID = "" -- Initialize selectedFaceID
if desc.Face and tonumber(desc.Face) and tonumber(desc.Face) > 0 then
selectedFaceID = desc.Face -- Get the faceID from the HumanoidDescription if it exists
end
game.ReplicatedStorage.trySingle:FireServer(selectedHatID, selectedFaceID)
end)
end
v.Activated:Connect(function()
for _, child in ipairs(script.Parent.Items.ScrollingFrame:GetChildren()) do
if child:IsA("ImageButton") and child.Frame then
child.Frame.Visible = false
end
end
v.Frame.Visible = true
end)
end
end
-- Trigger the tween animation to show the frame
local ItemsFrame = player.PlayerGui:WaitForChild("ScreenGui").ItemsFrame
triggerTweenAnimation(ItemsFrame, UDim2.new(0.865, 0, 0.5, 0), UDim2.new(0.235, 0, 0.560, 0))
end)
and this is my full tryon script, you can see from the productlist thats being fired that i have another button that equips everything from that mannequin, including faces:
local debounce = {}
game.ReplicatedStorage.productList.OnServerEvent:Connect(function(player, serial)
if not debounce[player.UserId] then
local desc = player.Character.Humanoid:GetAppliedDescription()
local mannequinDesc = serial.Humanoid.HumanoidDescription
-- Append the new hat to the existing accessories list
if mannequinDesc.HatAccessory then
if desc.HatAccessory == "" then
desc.HatAccessory = mannequinDesc.HatAccessory
else
desc.HatAccessory = desc.HatAccessory .. "," .. mannequinDesc.HatAccessory
end
end
if mannequinDesc.FaceAccessory then
if desc.FaceAccessory == "" then
desc.FaceAccessory = mannequinDesc.FaceAccessory
else
desc.FaceAccessory = desc.FaceAccessory .. "," .. mannequinDesc.FaceAccessory
end
end
if mannequinDesc.BackAccessory then
if desc.BackAccessory == "" then
desc.BackAccessory = mannequinDesc.BackAccessory
else
desc.BackAccessory = desc.BackAccessory .. "," .. mannequinDesc.BackAccessory
end
end
if mannequinDesc.Face ~= 0 then
desc.Face = mannequinDesc.Face
end
if mannequinDesc.Shirt ~= 0 then
desc.Shirt = mannequinDesc.Shirt
end
if mannequinDesc.Pants ~= 0 then
desc.Pants = mannequinDesc.Pants
end
if mannequinDesc.GraphicTShirt ~= 0 then
desc.GraphicTShirt = mannequinDesc.GraphicTShirt
end
player.Character:FindFirstChild("Humanoid"):ApplyDescription(desc)
debounce[player.UserId] = true
wait(1)
debounce[player.UserId] = nil
end
end)
game.ReplicatedStorage.trySingle.OnServerEvent:Connect(function(player, itemID, faceID)
if not debounce[player.UserId] then
local desc = player.Character.Humanoid:GetAppliedDescription()
-- Append the new item to the existing accessories list for HatAccessory
if itemID and tonumber(itemID) then
if desc.HatAccessory == "" then
desc.HatAccessory = itemID
else
desc.HatAccessory = desc.HatAccessory .. "," .. itemID
end
end
-- Set the face to the new faceID if it's valid
if faceID and tonumber(faceID) then
desc.Face = faceID
end
player.Character.Humanoid:ApplyDescription(desc)
debounce[player.UserId] = true
wait(1)
debounce[player.UserId] = nil
end
end)