Hello , I started scripting not long ago and I’m trying to make a code that gives the player’s accessories to a dummy. Except that the problem is that I don’t understand why it doesn’t work (I put this code in a local script in a “text button”)
local dummy = game.Workspace.Effaceur_objets
local bouton = script.parent
bouton.MouseButton1Click:Connect(function(player)
local d = player.Parent:GetChildren()
for i=1, #d do
if (d[i].className == "Accessory") then
d[i].Parent = dummy
print(i .. ' Objet donné au dummy ☑️')
end
end
end)
player.Parent.MouseButton1Click:Connect(player)
It works with part. ( don’t pay attention to the hair that has appeared)
local dummy = game.Workspace.Effaceur_objets
local bouton = script.Parent
local player = game.Players.LocalPlayer
bouton.MouseButton1Click:Connect(function()
local d = player.Character:GetChildren()
for i=1, #d do
if (d[i].className == "Accessory") then
d[i].Parent = dummy
print(i .. ' Objet donné au dummy ☑️')
end
end
end)