So I've got this local script inside of a clickable gui and all
'Username' is a text box the player can enter another players username
local name = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() name.Backpack:GetChildren():Clone().Parent = game.Players:FindFirstChild(script.Parent.Parent.Username.Text).Backpack name.Backpack:GetChildren():Destroy() end)
When they click this gui button its supposed to take the players inventory and give it to the other player
It just down right isn't working. I've gone through many methods and rewrites of this but they just will not work.
No errors or anything popping up its just not working at all, the first players items dont get destroyed and the other player doesn't get any items.
Any ideas as to why this isn't working?
Edit: I tried to take peoples items individually that they were holding but that too didnt work
Well, doing object:GetChildren():Clone()
will result into an error, cuz as you may now :GetChildren()
returns a table containing the object's children. And you can't use :Clone() on a table can you. Always think logiclly when you're scripting, remember what each function returns. I'm not sure if you're famaliour with in pairs
loops. I hope you are cuz were gonna use those here. And just in case.
local name = game.Players.LocalPlayer local wanted = game.Players:FindFirstChild(script.Parent.Parent.Username.Text) script.Parent.MouseButton1Click:connect(function() for i, v in pairs (name.Backpack:GetChildren()) do if wanted then v.Parent = wanted.Backpack end end end)
It's actually that easy! And really sorry for not explaining xd the link I gave you is sure way helpful.