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)