Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[UNANSWERED] Why is my item not a valid member of Backpack?

I am making a test game, and I thought you could access backpack items just by calling,

``

   player.Backpack.ITEM

But I guess you can't, because I am getting the error, ``

    10:53:33.764 - Wand is not a valid member of Backpack

Here is my server script that is being called from a localscript when the wand is activated, ``
local repStorage = game:GetService("ReplicatedStorage") local castSpellEvent = repStorage:WaitForChild("CastSpell")

     castSpellEvent.OnServerEvent:connect(function(player, word)
print(word)
if word == "ReFe" then
	local yeet = player:WaitForChild("Backpack")
			print("ReFe FIREWHIP")
			
	local ray = Ray.new(yeet.Wand.Handle.CFrame.p, 
      yeet.Wand.Handle.CFrame.p.unit * 300)
	
 local part, position = workspace:FindPartOnRay(ray, player.Character, true, true)
	local beam = Instance.new("Part", workspace)
	beam.Name = "FireWhip"
	local distance = (player.Character.HumanoidRootPart.Position - position).magnitude
	beam.BrickColor = BrickColor.new("Bright red")
	beam.Locked = true
	beam.Anchored = true
	beam.Size = Vector3.new(0.3, 0.3, distance)
	beam.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position, 	
             position) * CFrame.new(0, 0, -distance / 2)	
		
	


	if part then
    local humanoid = part.Parent:FindFirstChild("Humanoid")

  if not humanoid then
	humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
  end

  if humanoid then
	humanoid:TakeDamage(30)
end
 end
	
end
   end)

1 comment

0

Sorry for the terrible formatting, I don't really understand how to use the code blocks on here.

2 answers

✓ Accepted answer

When the wand is equipped, it is placed inside the character. You should do:

player.Character:WaitForChild('Wand')

Quick tip: When using the unequip event on a tool, and doing something to the tool, remember to do

player.Backpack.Wand

instead. Put it simply: Only use player.Backpack.Wand when it isn't equipped.

1 comment

0

WaitforChild isn't a valid member of model

Do player.Backpack:WaitForChild("Wand")

3 comments

0

Thanks for the help, but it says, Infinite yield possible on 'Players.WorkAtChickenPlace.Backpack:WaitForChild("Wand")'

0

That means the wand isn't there

0

Then where is it?

This discussion is preserved as it was. New answers, comments, and votes are closed.