Ok, so I was making a game and this script did not work. And I was wondering if anyone could help.
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 script.Parent.Parent.BeanPosition.Script.Disabled = true hit.Parent.Beans:Destroy() game.ReplicatedStorage.Time.Value = game.ReplicatedStorage.Time.Value - 30 end end) end while wait(5) do spawn(touched) end