I am making a hat dispenser, when inputted an id, the dispenser will equip the hat to the character of the player. I am using a serverside script and a RemoteFunction to gain access to InsertService from the client. Everything works fine, there are no errors, but when it gets to Humanoid:AddAccessory(), it doesn't equip the hat.
Server script:
game.ReplicatedStorage.Insert.OnServerInvoke = function(player, id)
local a = game:GetService("InsertService"):LoadAsset(id)
print(a)
a.Parent = game.ReplicatedStorage
return a
end
Client Script:
local gui = script.Parent
gui.TextButton.MouseButton1Click:Connect(function()
print(tonumber(gui.TextBox.Text))
local acc = game.ReplicatedStorage.Insert:InvokeServer(tonumber(gui.TextBox.Text))
print(acc)
game.Players.LocalPlayer.Character.Humanoid:AddAccessory(acc:GetChildren()[1]) --This doesn't equip the hat.
end)

2 comments
To elaborate further, it does equip the accessory, but the accessory is underneath the baseplate, stuck. This must be an attachment problem.
I have fixed it by moving everything that has to do with the accessory to the client.