deleted
sorry for my mistake guys,
I didn’t know it was wrong, and if I did I wouldn’t do it. thank you very much even to those who told me this was wrong
and I will not do it again
You’ll want to use a LocalScript here and Connect on MouseButton1Click of your TextButton, when it’s fired you should use FireServer on a RemoteEvent passing the Text (name of the Player to fuse with) of your input TextBox.
Obviously, Connect on OnServerEvent of that RemoteEvent and check if the Player exists (via Players::FindFirstChild) - if they do then iterate through GetChildren of the person who fired the RemoteEvent’s Character, Cloning and Destroying every Accessory Instance. Finally, use Humanoid::AddAccessory and add all of the new cloned Accessories.
An example of fusing would be:
local function Fuse(Player, TargetPlayer)
local Accessories = {}; --// Array to hold the newly cloned Accessories
for _, Child in ipairs(Player.Character:GetChildren()) do --// Iterate through every Child of the Character
if (Child:IsA("Accessory")) then
Child:Destroy();
table.insert(Accessories, Child:Clone()); --// Insert the new clone into the array
end
end
for _, Accessory in ipairs(Accessories) do --// Iterate over every new clone
TargetPlayer.Character.Humanoid:AddAccessory(Accessory); --// Add it to the target player
end
end
The OP asked how it would be done, didn’t explicitly ask to program the entire system as I haven’t done. It is fine to ask in this category how you can achieve something.
Oh, that makes a lot of sense. I’m fairly new, so I must have misread the guidelines.
This is saying Text.Character
which is not a valid property of Text. You have to find the player in game.Players
for _, Accessory in ipairs(Accessories) do --// Iterate over every new clone
game.Players[TargetPlayer].Character.Humanoid:AddAccessory(Accessory); --// Add it to the target player
end
Also this entire bit here
for _, Child in ipairs(Player.Character:GetChildren()) do --// Iterate through every Child of the Character
if (Child:IsA("Accessory")) then
Child:Destroy();
table.insert(Accessories, Child:Clone()); --// Insert the new clone into the array
end
end
for _, Accessory in ipairs(Accessories) do --// Iterate over every new clone
TargetPlayer.Character.Humanoid:AddAccessory(Accessory); --// Add it to the target player
end
could be changed to this. (without :Destroy
because you never said you wanted to destroy the accessories
for _, Child in ipairs(Player.Character:GetChildren()) do --// Iterate through every Child of the Character
if (Child:IsA("Accessory")) then
local accessory = Child:Clone()
game.Players[TargetPlayer].Character.Humanoid:AddAccessory(accessory)
end
end