Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i get a location of item held by player?

Asked by
Yuuwa0519 197
5 years ago
Edited 5 years ago

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)
0
Is this a tool? If it is then, you can find it under a `player.Character` if it is equipped. When it is unequipped it will automatically be sent back to the `player.Backpack` NickAtNick 163 — 5y
0
Yes 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 Yuuwa0519 197 — 5y

Answer this question