Hi there! What I am trying to achieve is a key which collides into a door, and then you can click the door handle to unlock the door. Issue is, when I try to collide the key with the door, it says “infinite yield possible workspace.Captchasolverv3:WaitForChild(“Key”). When I try the door and key in a different game file it works perfectly fine, but when it’s in my main game it has issues. I’ve done some research and it also turns out that infinite yield possible means it might take forever to find what it is that you are trying to find which in this case is a key inside the starter pack. Any ideas??
What Infinite Yield means is that it likely doesn’t exist / will never exist. It will just keep looking forever until found. I get that warning all the time, but I always make sure it will load eventually. In your case, Key
is non existent (nil) in Captchasolverv3. If it works just fine, you don’t need to worry about it.
Can I have a look at the explorer when you are playing the game inside of Studio?
function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
local g=hit.Parent.Name
local BackPack = game.Players.LocalPlayer
local jet = hit.Parent:WaitForChild("Key")
script.Parent.Parent.Locked.Value = false
script.Parent.Lock:Play()
jet:Destroy()
end
end
script.Parent.Touched:Connect(onTouched)
there really is no need for a wait for child. What are you waiting for?
it is usually used when something happens at the start of the game like when they may not be loaded in.
If the player does not have a key, then the script will infinitely yield until it finds that key (which it won’t)
Instead, simply check if the player has a key
The revised code should look like:
function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
local g=hit.Parent.Name
local BackPack = game.Players.LocalPlayer
if hit.Parent:FindFirstChild("Key") then
local jet = hit.Parent["Key"]
script.Parent.Parent.Locked.Value = false
script.Parent.Lock:Play()
jet:Destroy()
end
end
end
script.Parent.Touched:Connect(onTouched)