Safezone (You receive the tools you had out of the safezone)

Hello, I am trying to make a Safezone, where you receive the tools you had outside of it.

The issue is that it doesn’t give the players their tools back when they walk out, can anyone help me?

--Store Tools/Create Folder
script.Parent.Touched:Connect(function(Hit)
    local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)

    if plr and plr:FindFirstChild(plr.Name.." Tools") == nil then
        local Folder = Instance.new("Folder")
        Folder.Name = plr.Name.." Tools"
        Folder.Parent = game.ReplicatedStorage

        for _, v in pairs(plr.Backpack:GetChildren()) do
            if v:IsA("Tool") then
                v.Parent = Folder
            end
        end

        for _, v in pairs(Hit.Parent:GetChildren()) do --Also account for the Character's Model when they have a Tool equipped
            if v:IsA("Tool") then
                v.Parent = Folder
            end
        end

    end
end)
--Parent Tools Back to the Player

script.Parent.Touched:Connect(function(Hit)
    local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
    
    if plr then

        local Folder = game.ReplicatedStorage:FindFirstChild(plr.Name.." Tools")
        if Folder then

            for _, v in pairs(plr.Backpack:GetChildren()) do
                if v:IsA("Tool") then
                    v.Parent = plr.Backpack
                end
            end

        end
    end
end)
1 Like

Use the TouchEnded event to check when the player moves out of the block. Then just parent their tools back to their backpack

1 Like