Hello.
I am currently attempting to make a barrier where you need a specific amount of pets to go through. I thought this would work by making it go through a for loop, however i get the error attempt to compare number and Instance. Not sure what is caused by this, and would like some help. Here's my script:
local Player = game:GetService("Players").LocalPlayer
local PetFolder = Player:WaitForChild("Pets")
local Barrier = workspace:WaitForChild("5 Pets Barrier").Barrier:FindFirstChild("Main Barrier")
for _, PetAmount in pairs(PetFolder:GetDescendants()) do
if PetAmount >= 5 then
Barrier.CanCollide = false
Barrier.BrickColor = BrickColor.new("Lime green")
end
end
I am stuck on this and would like some help. Thanks

1 comment
That worked very well. Thanks!