Clear inventory zone

Perhaps I should have elaborated with what I was explaining. Applying this locally disables the GUI for the player locally.

I don’t think I misunderstood anything.

Right, but an exploiter can re-enable the interface locally and then is able to re-equip their tools on the server. Moreover an exploiter doesn’t even need the interace, they can simply use one of the following actions instead.

Both of the following actions will replicate to the server (providing the tools were created on the server).
Humanoid:EquipTool(Tool)
Humanoid.UnequipTools()

Hence, that is why I said:

There would be no need for all the other legwork described.

This suggestion was only made after my initial reply.

My condolences. Like I said, I probably should’ve elaborated in my original post further, but this was part of the idea the whole time. In fact, it’s the exact same system I use in my games.

Ig that I did setup this wrong way, can you help me with this?
“ToolsSafeZone” Is a folder in ReplicatedStorage.
I did put that script that you sent me in ServerSriptService.

local Game = game
local Workspace = workspace
local Players = Game:GetService("Players")
local RunService = Game:GetService("RunService")
local Part = Workspace.Part

local PlayersTable = {}

local function OnHeartbeat()
	local Parts = Workspace:GetPartsInPart(Part)
	
	for _, Player in ipairs(Players:GetPlayers()) do
		local Character = Player.Character
		local Backpack = Player:FindFirstChildOfClass("Backpack")
		if not (Character and Backpack) then continue end
		local State
		for _, Child in ipairs(Character:GetChildren()) do
			if not (Child:IsA("BasePart")) then continue end
			if table.find(Parts, Child) then State = true break end
		end
		
		if State then
			if PlayersTable[Player] then continue end
			local Items = Backpack:GetChildren()
			local Item = Character:FindFirstChildWhichIsA("BackpackItem")
			if Item then table.insert(Items, Item) Items.State = true end
			PlayersTable[Player] = Items
			for _, Item in ipairs(Items) do
				Item.Parent = nil
			end
		else
			local Items = PlayersTable[Player]
			if not Items then continue end
			if Items.State then table.remove(Items, #Items).Parent = Character end
			for _, Item in ipairs(Items) do
				Item.Parent = Backpack
			end
			PlayersTable[Player] = nil
		end
	end
end

local function OnPlayerRemoving(Player)
	PlayersTable[Player] = nil
end

RunService.Heartbeat:Connect(OnHeartbeat)
Players.PlayerRemoving:Connect(OnPlayerRemoving)

Cleaner implementation, haven’t had chance to test.
local Part = Workspace.Part
Only this line should need changing.

It is still not working, I tried it several times, sometimes it gave me items back first time, but after returning to zone and then leaving it never gave me the items back then.
There are not errors in console just to let you know.

Slight typo on my end, replace ‘Item’ inside ‘()’ of the following line with ‘BackpackItem’.
local Item = Character:FindFirstChildWhichIsA("Item")
This is what retrieves the character’s currently equipped tool (if they have a tool equipped). Here’s the script in action.

https://gyazo.com/9ac2bef9bf420a0bbfa8882e6506b9cc

The ‘Zone’ should be an anchored part with its collisions disabled.

Hello, with what should I replace it? With the “BackpackItem”? I replaced it with that and it is still not working. I can show it to you in-game if you want.

This is the whole script, maybe I mistyped something.
local Game = game
local Workspace = workspace
local Players = Game:GetService(“Players”)
local RunService = Game:GetService(“RunService”)
local Part = Workspace.ZoneTouch

local PlayersTable = {}

local function OnHeartbeat()
local Parts = Workspace:GetPartsInPart(Part)

for _, Player in ipairs(Players:GetPlayers()) do
	local Character = Player.Character
	local Backpack = Player:FindFirstChildOfClass("Backpack")
	if not (Character and Backpack) then continue end
	local State
	for _, Child in ipairs(Character:GetChildren()) do
		if not (Child:IsA("BasePart")) then continue end
		if table.find(Parts, Child) then State = true break end
	end

	if State then
		if PlayersTable[Player] then continue end
		local Items = Backpack:GetChildren()
		local Item = Character:FindFirstChildWhichIsA("BackpackItem")
		if Item then table.insert(Items, Item) Items.State = true end
		PlayersTable[Player] = Items
		for _, Item in ipairs(Items) do
			Item.Parent = nil
		end
	else
		local Items = PlayersTable[Player]
		if not Items then continue end
		if Items.State then table.remove(Items, #Items).Parent = Character end
		for _, Item in ipairs(Items) do
			Item.Parent = Backpack
		end
		PlayersTable[Player] = nil
	end
end

end

local function OnPlayerRemoving(Player)
PlayersTable[Player] = nil
end

RunService.Heartbeat:Connect(OnHeartbeat)
Players.PlayerRemoving:Connect(OnPlayerRemoving)

I’m unable to reproduce whatever problem it is that you are facing, all I can suggest is that you check the video I provided and attempt to mimic it.

Can you please share with me file of the place where it is setuped?

Reproduction.rbxl (48.0 KB)

Here you go.

1 Like