Item script error

Hello, the lost people,

I have a problem with interact item script. I try to detect the person who click the item have tag “Player”. There are no error at the output.

Item Script:

local CollectionService = game:GetService("CollectionService")

local toolTips = {
	RedKey = "Unlock red lock",
	YellowKey = "Unlock yellow lock",
	GreenKey = "Unlock green lock",
	BlueKey = "Unlock blue lock",
	Crowbar = "Use to break plank",
	Wrench = "Use to fix switch"

local function interact(item, player)

	local checkBackpack = player.Backpack:FindFirstChildWhichIsA("Tool")
	local checkCharacter = player.Character:FindFirstChildWhichIsA("Tool")
	local character = game.Players:GetPlayerFromCharacter(player.Character)

	if checkBackpack or checkCharacter then
		local oldItem = checkBackpack or checkCharacter
		oldItem.Handle.Detector.MaxActivationDistance = 23
		oldItem.Parent = item.Parent
		oldItem.Handle.CanTouch = false
		oldItem.Handle.Anchored = true
		oldItem.Handle.CFrame = item.Handle.CFrame * CFrame.Angles(0, math.rad(45), 0)

	item.Handle.Anchored = false
	item.Handle.CanTouch = true
	item.Parent = player.Character

for _, item in pairs(CollectionService:GetTagged("Item")) do	
		local character = player.Character
		if CollectionService:HasTag(character, "Player") then
			if character and character:WaitForChild("Humanoid").Health > 0 then
				item.Handle.Detector.MaxActivationDistance = 0
				interact(item, player)

	item.ToolTip = toolTips[item.Name]
1 Like

Could you describe what it’s supposed to do?
You’re telling us what it doesn’t do, it would help if we knew what it should be doing.

It was an item interaction. After a player that have the “Player” tag click the item, the item must be in player character