Click Video
I’m creating a Halo Shop. But there was a problem, namely when Equipped Halo, all the accessories from my Char disappeared
I have tried several times, but failed can you guys help me???
Code
local function equip(player,tag)
local char = player.Character or player.CharacterAdded:Wait()
local head = char
for i,v in pairs (head:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
local taag = game.ReplicatedStorage.Tags:WaitForChild(tag).Tag:Clone()
taag.Tag.Text = tag
taag.Parent = char
player.TagEquipped.Value = tag
end
script.Parent.BuyEvent.OnServerEvent:Connect(function(player,tag,group)
local Tag = game.ReplicatedStorage.Tags[tag]
local Currency = player.leaderstats[game.ReplicatedStorage.Tags.Currency.Value]
local Price = Tag.Price
if Currency.Value >= Price.Value and player.Tags:FindFirstChild(tag) and player.Tags[tag].Value == false and not Tag.Price:FindFirstChild("ID") and not Tag.Price:FindFirstChild("Group") then
Currency.Value = Currency.Value - Price.Value
player.Tags[tag].Value = true
elseif player.Tags:FindFirstChild(tag) and player.Tags[tag].Value == true then
equip(player,tag)
elseif player.Tags:FindFirstChild(tag) and Tag.Price:FindFirstChild("Group") and group == true then
equip(player,tag)
end
end)
I think the code in the equip function is what deletes the accessories from the character. If you are trying to stop this from happening, you can get rid of the code:
for i,v in pairs (head:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
This is the code that deletes the stuff in the top function.
I am not sure if this answers your question base on how you worded it, but I hope this helps!
Is the code to destroy the accessories supposed to only supposed to delete the currently equipped halo? The code doesn’t specify what accessory so it just deletes them all.
yeah, it looks like he’s trying to remove any previous halos before equipping the new one; is “Tag” the name of the new halo accessory you’re applying to the player? if so, maybe try changing the snippet of code StackedBlocks mentioned so that it checks for any accessories with the same name as your halo accessory, “Tag” and only delete them if so