Hi everyone! I’m trying to make a script that gets the value of an IntValue that’s located inside of a tool in the players backpack from a script in ServerScriptService.
The issue is, I always get the error:
Hatchet is not a valid member of Backpack “Players.oopacity.Backpack”
but whenever I check my backpack in the explorer, the tool is there.
local cooldown
local function playerAdded(player)
local backpack = player:WaitForChild("Backpack")
local hatchet = backpack.Hatchet
cooldown = hatchet:WaitForChild("Configuration").Speed
end
I’m not including the full script because it’s just leaderstats, datastores and stuff but if anyone needs more information to try and solve the problem, I’ll send it right away. I’ve tried using local hatchet = backpack.Hatchet and other scripts to try and debug it but I haven’t been able to fix it. I’ve also checked the forums and other sources for a solution but I haven’t seen anyone with the same error or a solution to it.
local cooldown
local function playerAdded(player)
local backpack = player:WaitForChild("Backpack")
local hatchet = backpack:FindFirstChild("Hatchet")
if hatchet then
cooldown = hatchet:WaitForChild("Configuration").Speed
end
end
local cooldown
local function playerAdded(player)
local backpack = player:WaitForChild("Backpack")
local hatchet = backpack:WaitFortChild("Hatchet")
cooldown = hatchet:WaitForChild("Configuration").Speed
end
It should work if it waits for it instead of looking for it immediately.
The problem here was, you want to load an object that is loaded. Try using :FindFirstChild(), like on the given script below.
local cooldown
local function playerAdded(player)
local backpack = player:WaitForChild("Backpack")
local hatchet = backpack:FindFirstChild("Hatchet")
cooldown = hatchet:FindFirstChild("Configuration").Speed
end