Giving and Removing Tools

I currently have game passes that give tools to players when bought. They include gravity/speed coils and a boombox. I also currently have a zone where players step in and they are given a sword and when stepped out of, the sword is removed. I want to be able for the zone to also remove the game pass tools if bought when stepped in, but also given back when stepped out of, and was wondering how I should go about this.

Code for sword fight zone:

-- Get ZoneService
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local ZonePlus = require(4664437268)
local ZoneService = require(ZonePlus.ZoneService)
local starterGui = game:GetService("StarterGui")

-- Setup zone
local group = workspace.SwordArea
local zone = ZoneService:createZone("SwordArea", group, 0)


-- Create a safe zone by listening for players entering and leaving the zone
local safeZoneCheckInterval = 0
local swordAreaName = "PineapplesForLife"
local sword = game.ServerStorage.ClassicSword
sword.Name = swordAreaName

local connectionAdded = zone.playerAdded:Connect(function(player)
	local char = player.Character
	local swordarea = char and char:FindFirstChild(swordAreaName)
	if not swordarea then
		swordarea = sword:Clone()
		swordarea.Parent = char
		--//Unequips tools
		print(player.Name.." is in safe zone")
	end
end)

local connectionRemoving = zone.playerRemoving:Connect(function(player)
	local char = player.Character
	local swordarea = char and char:FindFirstChild(swordAreaName)
	if swordarea then
		swordarea:Destroy()
		print(player.Name.." is not in safe zone")
	end
end)

zone:initLoop(safeZoneCheckInterval)
1 Like

the easiest solution is to find the tool and call deactivate on it, which will unequip the tool or call acticate on it, which will activate it when you are in the area

i can see that you’re leaving the tool in server storage, so you’ll want to define it and then run a check on all characters to see if they’re in the savezone, or in your case, move the sword in and out of their backpack to server storage when the zone event fires