Disable tools in one area

yes

i put it there and i got the same error

What is Zone supposed to be? I put a boolvalue and remote event, they didnt work

Weird, works perfectly fine for me, Make sure to add a huge part that is anchored and CanCollide to false

One huge part? so, not a model with a lot of parts called lobby

Yes one part that is invisible and CanCollide is false

Like this but the transparency is 1
image

Dont you put something in replicated storage?

I think thats the problem

Put the module in replicated storage
add a part in workspace named “Zone”
After that add a Script inside of Server Script Service

local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = workspace.Zone
local zone = Zone.new(container)

zone.playerEntered:Connect(function(player)
	print(("player entered the zone!"):format(player.Name))
end)

zone.playerExited:Connect(function(player)
	print(("player exited the zone!"):format(player.Name))
end)

script.Disabled = true
local Zone = require(game:GetService("ReplicatedStorage").Zone)

local container = workspace.Zone

local zone = Zone.new(container)

zone.playerEntered:Connect(function(player)

print(("player entered the zone!"):format(player.Name))

end)

zone.playerExited:Connect(function(player)

print(("player exited the zone!"):format(player.Name))

end)

script.Disabled = true

Nothing Prints

If nothing works, its ok, its not a big deal anway

I see why, you are disabling the script.
Remove the disable line instead use this

local Zone = require(game:GetService("ReplicatedStorage").Zone)

local container = workspace.Zone

local zone = Zone.new(container)

zone.playerEntered:Connect(function(player)

print(("player entered the zone!"):format(player.Name))

end)

zone.playerExited:Connect(function(player)

print(("player exited the zone!"):format(player.Name))

end)

Now because you are disabling the tool What you could do is add this Script I sent you in server script service.

And when the Player enters you could disable their backpack By adding a Remote event in ReplicatedStorage called “RemoveTools”

zone.playerEntered:Connect(function(player)
     game.ReplicatedStorage.RemoveTools:FireClient(Player)
end) 

After that add a local script inside of StarterPlayerScripts.

game.ReplicatedStorage.RemoveTools.OnClientEvent:Connect(functioon()
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end)

So basically I tried to do what you said and I got errors
But I think I have found a better way

local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = workspace.Zone
local zone = Zone.new(container)

game.StarterPack.ClassicBomb.PlantBomb.Disabled = true

zone.playerEntered:Connect(function(player)
	print(("player entered the zone!"):format(player.Name))
end)



zone.playerExited:Connect(function(player)
	print(("player exited the zone!"):format(player.Name))
end)


Now, the tools stays disabled even when I leave the area

This script is quite old, but it still works when inside of the part:

If a player touches the part, all their tools will be removed from the Backpack.

local part = script.Parent

local function remove(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
    local player = game.Players:FindFirstChild(otherPart.Parent.Name)
    if humanoid and player then
        local inHand = otherPart.Parent:FindFirstChildWhichIsA('Tool')
        local inBackpack = player.Backpack:FindFirstChildWhichIsA('Tool')
        if inHand then
            inHand:Destroy()
        end
        if inBackpack then
            inBackpack:Destroy()
        end
    end
end

part.Touched:Connect(remove)

Does it add them back when they are out of the zone?

No it doesn’t unless you want to use TouchedEnded which is unreliable.

Just enable it back like I’ve given you an example when the Player enters.

Just do the steps but this time on the remote event do this

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

Are the tools that you want to get back, available to anyone who plays?

@lilmazen1234 also, how is the TouchEnded unreliable?

Some of the time Touched ended doesn’t work. (Very Unreliable)

A Topic about it (Check the Solution)

It would be better to use Zone Plus as it’s efficient unlike TouchedEnded

1 Like

Zone+ still works but I’d suggest using the spatial query API if you want a more lightweight implementation. Both methods should work well though.

If you want to hide the backpack, then you can do like this

  1. Add a local script into StarterPlayerScripts
    Capture
  2. Paste this code into the local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HideToolsEvent = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("HideTools")
local StarterGui = game:GetService("StarterGui")

HideToolsEvent.OnClientEvent:Connect(function(Value)
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, Value)
end)
  1. Add a folder into ReplicatedStorage and rename it to Remotes
    Capture
  2. Add a remote event into that folder and rename it to HideTools
    Capture
  3. Add in the zone plus module into ReplicatedStorage
    Capture
  4. Add a part into workspace and name it Zone
    Capture
  5. Add a script into ServerScriptService and then paste this code into it
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Zone = require(ReplicatedStorage:WaitForChild("Zone"))
local container = workspace:WaitForChild("Zone")
local zone = Zone.new(container)
local HideToolsEvent = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("HideTools")

zone.playerEntered:Connect(function(player)
	HideToolsEvent:FireClient(player, false) -- Send false to hide the backpack
end)

zone.playerExited:Connect(function(player)
	HideToolsEvent:FireClient(player, true)
end)

and it should work just fine

robloxapp-20220815-2037475.wmv (630.4 KB)

Place file
Zone.rbxl (71.2 KB)

If you need any help with this let me know

It actually worked! Thanks for the help

And thanks to @lilmazen1234 for the info on zoneplus

1 Like