I'm trying to make a character creator and I have a GUI that allows players to choose a hair accessory to wear. Upon selection, an accessory is cloned unto players' character. I would like for players to be able to cycle through accessories, thus deleting the previously worn accessory and then cloning a new one. How do I identify and delete the previous clone within the script?
If any additional clarification is needed, please don't hesitate to ask me. All help is appreciated!
The script below is an idea of how I thought it'd work, but it didn't.
local clone = nil
function updateMidBox()
if clone ~= nil then --If a clone exists, delete it
clone:Destory()
end
if numb.Value > 0 then
midBox.Text = ("Hair: "..hairFolder[numb.Value].Name)
addAccoutrement(char, hairFolder[numb.Value])
local clone = hairFolder[numb.Value] --The new hair piece is defined as the "clone"
else
midBox.Text = ("Hair: None")
end
end
