Hey there, I’m trying to store a player’s tools in ReplicatedStorage when they leave a zone. I’m using ZonePlus and a remote event.
RepStorage.events.UnequipTools.OnServerEvent:Connect(function(player)
local PlayerTools = player.Character:FindFirstChildWhichIsA("Tool"):GetChildren()
local PlayerBackpackTools = player.Backpack:GetChildren()
for i, v in pairs(PlayerBackpackTools, PlayerTools) do
v.Parent = RepStorage
end
end)
I’m not sure how to loop through these two variables at the same time. Any help will be appreciated.
RepStorage.events.UnequipTools.OnServerEvent:Connect(function(player)
local PlayerTools = player.Character:FindFirstChildWhichIsA("Tool"):GetChildren()
local PlayerBackpackTools = player.Backpack:GetChildren()
for i, v in pairs(PlayerBackpackTools) do
v.Parent = RepStorage
end
for i, v in pairs(PlayerTools) do
v.Parent = RepStorage
end
end)
I created two functions - one looped through the player’s backpack, the other looped through the player’s character.
if player.Backpack:FindFirstChildWhichIsA("Tool") then
BackpackTools()
end
if player.Character:FindFirstChildWhichIsA("Tool") then
CharacterTools()
end
Using this code it checked if it found a tool in either of and if it did, it ran that function.