So I was trying to make something when if you touch something with a tool it will get taken out of your inventory and placed into the shrine. However, it will not work
local event = game.ReplicatedStorage.event
local function touched()
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Beans") then
script.Parent.Parent.BeanPosition.Transparency = 0
print("Player has beans!")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
print(player.Name.." needs their beans removed.")
local light = script.Parent.Parent.Carpet.SurfaceLight
light.Enabled = true
player.Backpack.Beans:Destroy()
script.Parent.Parent.BeanPosition.Script.Disabled = true
end
end)
end
while wait(5) do
spawn(touched)
end

4 comments
:(
what?
Have you checked the output?
yes, it says "Beans is not a valid member of Backpack" when it's in the player's inventory.