I’m using attributes in buttons and stuff to make a merch shop kind of like the one in Pls donate but the shirts and pants doesn’t appear unless I go into the explorer click on the shirt/pants then click the assetId then press enter on it. I tried multiple methods even AI but nothing works.
local rs = game:GetService("ReplicatedStorage")
local ts = game:GetService("TweenService")
local mps = game:GetService("MarketplaceService")
local player = game:GetService("Players").LocalPlayer
local modules = rs:WaitForChild("Modules")
local buttonModule = require(modules:WaitForChild("ButtonAnimator"))
local notoModule = require(modules.NotificationModule)
local uis = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local frame = script.Parent
local buttons = frame:GetChildren()
local dummyTemplate = rs:WaitForChild("R6Dummy")
-- Settings
local rotationSensitivity = 0.5
local zoomSensitivity = 1
local minZoom = 4
local maxZoom = 12
local function promptPurchase(button)
local assetId = button:GetAttribute("AssetId")
if assetId then
mps:PromptPurchase(player, assetId)
else
warn("Missing AssetId attribute on button")
end
end
for _, button in ipairs(buttons) do
if button:IsA("GuiButton") and button:FindFirstChild("ViewportFrame") then
local viewportFrame = button.ViewportFrame
local assetType = button:GetAttribute("AssetType") -- "Shirt" or "Pants"
local assetId = button:GetAttribute("AssetId")
-- Create world model
local worldModel = Instance.new("WorldModel")
worldModel.Parent = viewportFrame
-- Clone dummy
local dummy = dummyTemplate:Clone()
dummy:SetPrimaryPartCFrame(CFrame.new(0, 1, 0))
dummy.Parent = worldModel
-- Add clothing
if assetType == "Shirt" then
local shirt = Instance.new("Shirt")
shirt.Parent = dummy
task.wait(0.1)
shirt.ShirtTemplate = tostring(assetId)
elseif assetType == "Pants" then
local pants = Instance.new("Pants")
pants.Parent = dummy
task.wait(0.1)
pants.PantsTemplate = tostring(assetId)
else
end
local zoomDistance = minZoom
local camera = Instance.new("Camera")
camera.CFrame = CFrame.new(Vector3.new(0, 1, zoomDistance), Vector3.new(0, 1, 0))
viewportFrame.CurrentCamera = camera
camera.Parent = viewportFrame
buttonModule.Animate(button, nil, { 1.1, 0.95 })
button.MouseButton1Up:Connect(function()
promptPurchase(button)
end)
local dragging = false
local lastPos
local lastInputTime = tick()
local dummyAngle = 0
local autoRotateSpeed = math.rad(math.random(15, 40) / 60)
local idleStartDelay = math.random()
button.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
lastPos = input.Position
end
end)
button.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = false
end
end)
button.InputChanged:Connect(function(input)
if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
local delta = input.Position - lastPos
lastPos = input.Position
dummyAngle = dummyAngle - math.rad(delta.X * rotationSensitivity)
dummy:SetPrimaryPartCFrame(CFrame.Angles(0, dummyAngle, 0) + Vector3.new(0, 1, 0))
lastInputTime = tick()
end
end)
uis.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseWheel then
local mouse = uis:GetMouseLocation()
local pos = viewportFrame.AbsolutePosition
local size = viewportFrame.AbsoluteSize
local inside = mouse.X >= pos.X and mouse.X <= pos.X + size.X and
mouse.Y >= pos.Y and mouse.Y <= pos.Y + size.Y
if inside then
zoomDistance = math.clamp(zoomDistance - input.Position.Z * zoomSensitivity, minZoom, maxZoom)
lastInputTime = tick()
end
end
end)
runService.RenderStepped:Connect(function()
if not dragging and tick() - lastInputTime > 2 + idleStartDelay then
dummyAngle += autoRotateSpeed
dummy:SetPrimaryPartCFrame(CFrame.Angles(0, dummyAngle, 0) + Vector3.new(0, 1, 0))
end
camera.CFrame = CFrame.new(Vector3.new(0, 1, zoomDistance), Vector3.new(0, 1, 0))
end)
end
end
sry abt the sloppy code