I am having problem to find the specific item in my game called "keyTorch". This makes item get held by player if picked and also toggles the color of eye of totem pole but after it is picked i cant find a way to define this object. also, this game is parkour-type game so i have my model in serverstorage to spawn new one in case the player falls and is lost, but cant find a way to know if the torch is really lost or is held by player. sorry for my bad grammars.
--code (for checker to see if the key is held by player or it is lost)
local totemEye1 = script.Parent.eye1
local totoemEye2 = script.Parent.eye2
local players = game.Players
local originalkeyTorch = game.ServerStorage:WaitForChild("keyTorch")
local originalkeyPosition = originalkeyTorch.Handle.Position
local keyTorchLostDetector = script.Parent.keyLostDetector
local torchBackDetector = script.Parent.Parent.torch1Checker
local keynotDestroyed = true
local keystolen = false
keyTorchLostDetector.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")then
print("the visible key torch is about to get stealed by player")
wait(20)
if game.Workspace:FindFirstChild("visiblekeyTorch")~= game.Workspace then
print("the key is not in original Place")
keystolen = true
if [[--apperantly this part doesn`t work--]] game.Workspace:FindFirstChildOfClass("Model"):FindFirstChild("visiblekeyTorch") or game.Workspace:FindFirstChildOfClass("Model"):FindFirstChild("BackPack"):FindFirstChild("visiblekeyTorch") then
print("the key is in player")
else
print("the key is not found")
keystolen = false
local cloneKey = originalkeyTorch:Clone()
cloneKey.Name = "visiblekeyTorch"
cloneKey.Parent = game.Workspace
print("the key was loaded")
end
end
end
end)

2 comments
Is this a tool? If it is then, you can find it under a
player.Characterif it is equipped. When it is unequipped it will automatically be sent back to theplayer.BackpackYes it is a tool. Is this way possible when for example there is player a,b,c, and d, and if player "b" has the tool i can know that the tool is held by one of the player without having to know who exactly has it? Thank you