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

using findFirstChild in Player's Backpack?

Hi, as the Title sais I'm trying to locate 2 tools which are both called "atlas sword" using findFirstChild method. but for some reason it won't work. here's the script:

local player = game.Players.LocalPlayer 
local l = player.Backpack:findFirstChild("atlas sword") 
script.Parent.MouseButton1Click:connect(function()
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,277976767) then
        game.Lighting["atlas sword"]:Clone().Parent = player.Backpack
    if l then
	l:Remove()
end
    end
end)



Thanks for the Help.

1 answer

✓ Accepted answer

You were making it remove the tool right after it gave the player it, also not sure why the local l = player.Backpack:findFirstChild("atlas sword") won't work, but here's a script that'll work for what you want. Sorry I can't explain it any better.

local player = game.Players.LocalPlayer 
 
script.Parent.MouseButton1Click:connect(function()
	if player.Backpack:FindFirstChild("atlas sword") then
    	player.Backpack["atlas sword"]:Remove()
end
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,277976767) then
    	game.Lighting["atlas sword"]:Clone().Parent = player.Backpack
	end
end)

1 comment

0

Cheers

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