Attempting to make it so that once a user picks up a tool, it is locked to them and if someone else picks it up they cannot use it

  1. What do you want to achieve?
    I am trying to make it so that once a user picks up a tool and equips, it changes a value inside of the tool to their UserID, and whenever it is equipped it checks the UserID of the person equipping it, and if it isn’t the UserID stored in the value, it forces them to unequip the tool.
  2. What is the issue?
    I have it coded so that when the person who the tool is locked to, it prints that it was equipped by the right person, but if it is equipped by somebody who it isn’t locked to, it prints that it was equipped by the wrong person, and fires the UnequipTools function on their humanoid. Instead of this, whenever someone who it isn’t locked to equips it, it prints that it was equipped and doesn’t cause the player to unequip the tool.
  3. What solutions have you tried so far?
    I’ve looked around the devforum and haven’t been able to find any solutions. I’ve tried making it so the tool gets parented to the player’s backpack upon equipping it or gets parented to workspace, but it just does nothing and gives me an error saying
--Something unexpectedly tried to set the parent of LockedToolTest to Backpack while trying to set the 
--parent of LockedToolTest. Current parent is lodyu.

I’ve also tried this out of studio with the game published with another player and it still gives this error.
The hierarchy of my tool is

LockedToolTest (Tool)

LockHandler (ServerScript)
LockedTo (IntValue)
Handle (BasePart)

My current code in the ServerScript is

local tool = script.Parent
local PlayerService = game:GetService("Players")

tool.Equipped:Connect(function()
	local char = tool.Parent
	local hum = char.Humanoid
	local player = PlayerService:GetPlayerFromCharacter(char)
	if tool.LockedTo.Value == 0 then
		tool.LockedTo.Value = player.UserId
	else if tool.LockedTo.Value ~= 0 and tool.LockedTo.Value == player.UserId then
			print("Biolock tool equipped by LockedTo")
		else if tool.LockedTo.Value ~= 0 and tool.LockedTo.Value ~= player.UserId then
				hum:UnequipTools()
				print("Biolocked tool equip attempted by ~= LockedTo")
			end
		end

	end
end)

If anyone knows what is causing this or some kind of fix, please let me know.