I can't figure out why this doesn't work at all

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

What exactly is the issue?

Can you show us the asset hierarchy?

Are you sure the if statement is going through?

do any errors occur?
try adding a wait up top and see if that changes anything

No errors occurs but the print statements also don’t occur

Basically this entire script won’t work somehow I added print statements to check it but even those don’t appear

wait for the apperance to load using plr.CharacterAppearanceLoaded:wait()

I get the error CharacterApperanceLoaded is not a valid member of Model “Workspace.Pofrow” when I try to use it

game.Players.LocalPlayer.CharacterAppearanceLoaded:wait()

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 = 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

Setting the parent doesn’t change anything it’s already inside of the right location it just needs to be cloned and follow the other steps

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.