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

How to check somethings parent?

Here is my code, I cant figure it out.

if Hammer.Handle = game.LocalBackpack
	
end

Thanks.

1 answer

You coded it wrong, lets fix that [Would do inside tool];

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer:FindFirstChild("Backpack") and script.Parent --I like to use this so that the script will repeat waiting until the requiements are found; this will repeat waiting until the Player, Player's Backpack, and Tool spawns
local plr = game.Players.LocalPlayer --This is the Player
local backpack = plr.Backpack --This is the Player's Backpack

if script.Parent.Parent == backpack then --This will check to see if the Tool's Parent is in the Player's Backpack [You forgot the 'then', and didn't include '.Parent', so it couldn't check the Parent]
print('I\'m in '..plr.Name..'\'s Backpack!') --It will print 'I'm in [Player's Name]'s Backpack!'
end --This ends the code for the 'if' statement

script means the script [Represents the Script], script.Parent means the script's Parent [Represents the Script's Parent], .Parent represents the Parent for an object. Hope this helped!

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