Not a valid member

Hello everyone, I’m scripting a game that is like Piggy using the tutorial from alvinblox,
In his tutorial he used:

if v.Backpack:FindFirstChild(“PiggyBat”) then v.Backpack.PiggyBat:Destroy() end
if v.Character:FindFirstChild(“PiggyBat”) then v.Backpack.PiggyBat:Destroy() end

I get this error from it:

PiggyBat is not a valid member of Backpack “Players.Player2.Backpack” - Server - RoundModule:168
09:37:36.546 Stack Begin - Studio
09:37:36.546 Script ‘ServerScriptService.Game Logic.RoundModule’, Line 168 - function RemoveTags - Studio - RoundModule:168
09:37:36.546 Script ‘ServerScriptService.Game Logic’, Line 94 - Studio - Game Logic:94
09:37:36.546 Stack End - Studio

(This error occurs when the round ends, and I’m holding the bat,however it works just fine if i un-equip the bat right before the round ends).

I’m not really sure how I can fix this, does anyone know how?

Looks like a simple error

You’re checking if the character has something called PiggyBat, and if it does, destroy something called Piggybat in the backpack. Make it destroy the one in the character

How exactly would I do that? I’m not really too experienced.

1 Like

Change that line to

if v.Character:FindFirstChild("PiggyBat") then v.Character.PiggyBat:Destroy() end
2 Likes