This script is located inside a screengui in startergui.
I have tried multiple variants of writing something like this none seem to work I even tried to use a module script but it still didn’t work.
I’m trying to clone Viewer which is supposed to show an accessory and when you press the X button the Viewer gets deleted and the accessory gets deleted too.
In short an Accessory remover Gui that removes the accessory that matches the Viewer Frame.
local plr = game.Players.LocalPlayer.Character
for i, v in pairs(plr:GetChildren()) do
if v:IsA("Accessory") or v:IsA("Hat") then
local frame = script.Parent.BodyP.Edit.Viewer
frame:Clone()
print("cloned")
frame.Visible = true
frame.Name = v.Name
frame.Label.Text = v.Name
frame.X.MouseButton1Click:Connect(function()
if v.Name == frame.Name then
frame:Destroy()
v:Destroy()
end
print("done")
end)
end
end
for i, v in pairs(plr:GetChildren()) do
if v:IsA(“Accessory”) or v:IsA(“Hat”) then
local frame = script.Parent.BodyP.Edit.Viewer
frame = frame:Clone()
print(“cloned”)
frame.Visible = true
frame.Name = v.Name
frame.Label.Text = v.Name
frame.X.MouseButton1Click:Connect(function()
if v.Name == frame.Name then
frame:Destroy()
v:Destroy()
end
print(“done”)
end)
frame.Parent = blablahblah <<<<< SET THE PARENT OF YOUR FRAME
end
end