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
Hello, If the player has the item equipped, then the tool is in their character.. please try the script below.
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 hit.Parent.Beans:Destroy() script.Parent.Parent.BeanPosition.Script.Disabled = true end end) end while wait(5) do spawn(touched) end
Please upvote if this works, Thank you.