Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't AddAccessory work with a valid accessory object but still prints error?[SOLVED]

Asked by
LuaDLL 253 Moderation Voter
5 years ago
Edited 5 years ago
if Data then
        local Tool = Tools:FindFirstChild(Data[1])
        Tool:Clone().Parent = player:WaitForChild("StarterGear")
        if not player:WaitForChild("Backpack"):FindFirstChild(Tool.Name) then
            Tool:Clone().Parent = player:WaitForChild("Backpack")
        end
        ToolB.Value = Tool.Name
        Cash.Value = Data[2]
        local Bag = Bags:FindFirstChild(Data[3])
        Char.Humanoid:AddAccessory(Bag) -- Errors here
        BagB.Value = Bag.Name
        Inbag.Value = Data[4]
        Maxbag.Value = Data[5]
    else
        local Tool = Tools:FindFirstChild("Coin")
        Tool:Clone().Parent = player:WaitForChild("StarterGear")
        if not player:WaitForChild("Backpack"):FindFirstChild(Tool.Name) then
            Tool:Clone().Parent = player:WaitForChild("Backpack")
        end
        ToolB.Value = Tool.Name
        Cash.Value = 100
        local Bag = Bags:FindFirstChild("Basic")
        Char.Humanoid:AddAccessory(Bag) -- Errors Here
        BagB.Value = Bag.Name
        Inbag.Value = 0
        Maxbag.Value = 5
    end

It errors saying AddAccessory needs to be passed a valid accessory Object but the Bag is an accessory?

0
well, idk, what is Bags refering to? starmaq 1290 — 5y
0
Is "Bags" a Folder or Model that contains the Accessory? Also the accessory, when added to the player must contain both an Attachment and a Handle SerpentineKing 3885 — 5y
0
yah thats true, but if it doesnt have one of those it will get added but it wont work, his accessory isnt getting parented in our case starmaq 1290 — 5y
0
Bags is a folder containing bags, and I have an attatchment and a handle in the accessory LuaDLL 253 — 5y
View all comments (6 more)
0
hmm starmaq 1290 — 5y
0
there must be a problem to the refering then starmaq 1290 — 5y
0
check your script starmaq 1290 — 5y
0
@Professional, go back to wherever you pre-defined "Bags" and make sure that the variable's definition matches the location of "Bags". Also, if "Bags" is in ServerStorage and you're running this from the Client, it will not replicate either. SerpentineKing 3885 — 5y
0
I fixed it, it was a problem with the attatchment LuaDLL 253 — 5y
0
But thanks for the help LuaDLL 253 — 5y

Answer this question