So currently I have a script that checking wether you’re backpack has these 3 exact items: Wood, wood and stone. (In any order) If they are there, then delete them and replace it with a sword kept in “lighting”
My script is… inefficent:
local Player = game.Players.LocalPlayer
local button = script.Parent
local Light = game:GetService("Lighting")
local woodClone = Light.Wood
local stoneClone = Light.Stone
button.MouseButton1Click:Connect(function()
local backpack = Player:WaitForChild("Backpack")
if backpack then
print("Found Player Backpack")
local woodCheck = backpack:FindFirstChild("Wood")
if woodCheck then
woodCheck:Destroy()
local woodCheck2 = backpack:FindFirstChild("Wood")
if woodCheck2 then
woodCheck2:Destroy()
local stoneCheck = backpack:FindFirstChild("Stone")
if stoneCheck then
print("2 wood and 1 stone")
stoneCheck:Destroy()
local strongsword = Light.SwordOfLight:Clone()
strongsword.Parent = backpack
else
stoneClone:Clone()
stoneClone.Parent = backpack
end
else
woodClone:Clone()
woodClone.Parent = backpack
print("1 wood")
end
else
print("No wood")
end
end
end)
Is there are more easier/efficent way of doing this??? Thanks!