--If this script has been installed already, we can stop this instance. Otherwise,
--this instance is the first to run of this version, so we'll install it to PlayerScripts.
--This is necessary because if we left it inside the Tool, it would stop running when the player
--dropped the tool or died, so our WeaponsSystem instance would be garbage-collected.

if ClientWeaponsScript and ClientWeaponsScript ~= script then
	return
else
	CollectionService:AddTag(script, "ClientWeaponsSystem")
	script.Parent = PlayerScripts
end
print("Starting ClientWeaponsScript")

local WeaponsSystemFolder = nil
local function searchForWeaponsSystem()
	local anyPossible = false
	for i, weaponsSystem in pairs(CollectionService:GetTagged(WEAPONS_SYSTEM_TAG)) do
		anyPossible = true
		if weaponsSystem:IsDescendantOf(ReplicatedStorage) then
			local systemVersionObj = weaponsSystem:WaitForChild("Version")
			if systemVersionObj and systemVersionObj.Value == ScriptVersion then
				WeaponsSystemFolder = weaponsSystem
				break
			end
		end
	end
	return anyPossible
end
