Hey, I’m sort of still learning scripting, and I’m currently trying to make a scrollingframe that’ll display the player’s current accessories, a bit like this:
i tried making it myself, but it doesnt work (obviously)
this is my script:
local Players = game:GetService("Players")
local template = script.Parent.ItemTemplate
local scrollingFrame = script.Parent.ScrollingFrame
local function populateAccessories(player)
for _, accessory in ipairs(player.Character:GetChildren()) do
if accessory:IsA("Accessory") then
local clone = template:Clone()
clone.Image = accessory.TextureID
clone.Parent = scrollingFrame
clone.Visible = true
end
end
end
local function clearAccessories()
for _, child in ipairs(scrollingFrame:GetChildren()) do
child:Destroy()
end
end
local function updateUI()
local player = Players.LocalPlayer
if player and player.Character then
clearAccessories()
populateAccessories(player)
end
end
updateUI()
Players.LocalPlayer.CharacterAdded:Connect(updateUI)
1 Like
hey!
ive never done soemthing like this before but i think ur on the right track. u have slots for each accessory. great. if u had say:
Brollow
SmarterThanRegan
1h
Hey, I’m sort of still learning scripting, and I’m currently trying to make a scrollingframe that’ll display the player’s current accessories, a bit like this:
image
i tried making it myself, but it doesnt work (obviously)
this is my script:
local Players = game:GetService("Players")
local template = script.Parent.ItemTemplate
local scrollingFrame = script.Parent.ScrollingFrame
local function populateAccessories(player)
for _, accessory in ipairs(player.Character:GetChildren()) do
if accessory:IsA("Accessory") then
local clone = template:Clone()
clone.Parent = scrollingFrame
clone.Visible = true
end
end
end
this would clone for how many accessories the character had. remember that this only gets the accessory. p sure u know that anyways! the slots should clone to the scrolling frame but they’ll be in the same position under each other so u need to seperate them. im not really sure how to do this but thats the first step.
another problem u have is this:
clone.Image = accessory.TextureID
textureID isnt a property of an accessory. u have to do:
for i, mesh in accessory:GetDescendants() do
if accessory:IsA("Mesh") then
clone.Image = mesh.TextureID
end
end
:GetAssetIdsForPackage()
is not the function to retrieve the player’s accessories. Humanoid:GetAccessories() is what you should use.
how would i get the accessories ID’s with that? I’m still trying to figure out how to