Infinite yield possible on 'Players.ohusq.Backpack:WaitForChild("Tool")' whilst being indexed correctly?

I’m trying to learn Rojo development and use it for client sided tool stuff and events.
But after indexing a tool called Tool it yields infinitely?

local tool : Tool = game:GetService("Players").LocalPlayer.Backpack:WaitForChild("Tool")

tool.Activated:Connect(function()
     print("Clicked.")
end)

-- Path: src\client\init.client.lua

image

1 Like

Strange you should actually get an error that the Backpack is not a member of the player. You have your script in StartPlayerScripts which occur before you even have a character and a tool. If you move your script up to StarterCharacterScripts it should work for you.

1 Like

How would I do this with Rojo in vs code?

Not familiar with rojo but from a quick look at their docs you’d need to add this to your project file:

    "StarterPlayer": {
      "$className": "StarterPlayer",

      "StarterCharacterScripts": {
        "$className": "StarterCharacterScripts",
        "$path": "src/StarterCharacterScripts"
      }
    },

Then make sure your init.client.lua is in that src directory.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.