-
What do you want to achieve?
I want a bag with items inside to hand to another person with the same contents. -
What is the issue?
When I try to hand the bag with items inside, it always hands it to the other person as an empty bag. -
What solutions have you tried so far?
I have tried many solutions, however they do not work.
Hi,
So basically I have made a system where you can package all the food in your inventory into a bag, then hand it to someone. I have made a hand-to system for this. However, it hands it to the other person as an empty bag.
Here are some photos:

Full bag before handing,

Empty after.

Bag code location.
Here is the client and server code:
Client (the hand-to GUI) -
local player = game.Players.LocalPlayer
local handTo = script.Parent.Parent.HandToText
script.Parent.MouseButton1Click:Connect(function()
local playername = script.Parent.Parent.HandToText.Text:lower()
local textboxcurrentname = 0
local playerchosen = nil
if handTo.Text ~= "" then
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name:lower() == playername then
playerchosen = v
print(playerchosen)
end
end
if playerchosen ~= nil then
print("Player found!")
if player.Character:FindFirstChildWhichIsA("Tool") then
game.ReplicatedStorage.HandTo:FireServer(playerchosen)
handTo.Text = ""
handTo.PlaceholderText = "Handed!"
wait(1)
handTo.PlaceholderText = "Hand to"
else
handTo.Text = ""
handTo.PlaceholderText = "Error, no tool equipped!"
wait(1)
handTo.PlaceholderText = "Hand to"
end
else
handTo.Text = ""
handTo.PlaceholderText = "Error, no player found!"
wait(1)
handTo.PlaceholderText = "Hand to"
end
else
handTo.Text = ""
handTo.PlaceholderText = "Error, no text!"
wait(1)
handTo.PlaceholderText = "Hand to"
end
end)
Server (hands the item) -
game.ReplicatedStorage.HandTo.OnServerEvent:Connect(function(plr, plrtogive)
local toolToGive = plr.Character:FindFirstChildWhichIsA("Tool")
toolToGive.Parent = game.Players[tostring(plrtogive)].Backpack
end)
The bag client code -
local plr = game.Players.LocalPlayer
local rs = game:GetService("ReplicatedStorage")
local itemValue = game:GetService("ReplicatedStorage").CloneStuff.Items
script.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if script.Parent.Name == "Empty Bag" then
local item = false
for i, v in pairs(plr.Backpack:GetChildren()) do
local o = v:FindFirstChildWhichIsA("BoolValue")
if o and o.Value == true then
v:Destroy()
local clone = itemValue:Clone()
clone.Parent = script.Parent
clone.Value = v.Name
item = true
end
end
if item == true then
script.Parent.Name = "Full Bag"
end
elseif script.Parent.Name == "Full Bag" then
for i, v in pairs(script.Parent:GetChildren()) do
if v.Name == "Items" then
if rs.Drinks:FindFirstChild(tostring(v.Value)) then
rs.Drinks:FindFirstChild(tostring(v.Value)):Clone().Parent = plr.Backpack
elseif rs.Food:FindFirstChild(tostring(v.Value)) then
rs.Food:FindFirstChild(tostring(v.Value)):Clone().Parent = plr.Backpack
end
v:Destroy()
end
end
script.Parent:Destroy()
end
end)
end)
Any help is appreciated,
Thanks!