Issue with dropper system

So i wanted to make a simple tycoon game to learn more about scripting, but i’ve encountered a issue with dropper system. It happened to me before and couldn’t fix so i decided to rescript the entire game xd, but it still doesn’t work. To put you in perspective whenever you buy something it will be in “PlayerBuilt” folder and i want to detect that the dropper is in that folder so i can start creating the parts are going to be sold. I tried everything i could, but i couldn’t fix the issue that it never meets the requirements of the if statement and always just prints the test even though the dropper is in the “PlayerBuilt” folder.

Here is the script and any help would be appreciated so much!

for _, dropper in pairs(CollectionService:GetTagged("Dropper")) do
	repeat wait(1)
		if dropper.Parent == PlayerBuilt then
			repeat wait(1)
				local product = Instance.new("Part", DropperParts)
				product.Anchored = false
				product.CanCollide = false
				product.Size = Vector3.new(1,1,1)
				product.Position = dropper.NewPartPos.Position
			until dropper == nil
		else
			print("Test")
		end 
	until dropper.Parent == PlayerBuilt
end

*Also this is not the full script, because it has around 150 lines, but i think the rest is not very immportant

Hi. As a side note, the current script you have wrote only loops through one dropper, and will never check if any of the other droppers meet the requirements. This is because the repeat function yields the rest of the script from running, so you can wrap the repeat function in task.spawn or coroutine.

More information here: coroutine | Documentation - Roblox Creator Hub, task | Documentation - Roblox Creator Hub.

Implementing this into your code would look something like this:

for _, dropper in pairs(CollectionService:GetTagged("Dropper")) do
    task.spawn(function()
	    repeat wait(1)
		    if dropper.Parent == PlayerBuilt then
			    repeat wait(1)
				    local product = Instance.new("Part", DropperParts)
				    product.Anchored = false
				    product.CanCollide = false
				    product.Size = Vector3.new(1,1,1)
				    product.Position = dropper.NewPartPos.Position
			    until dropper == nil
		    else
			    print("Test")
		    end 
	    until dropper.Parent == PlayerBuilt
    end)
end

Aside from this, I modified your code to a point where I could test it without needing the variables, tags, and folders you declared. When I ran this code, it worked perfectly fine:

for _, dropper in pairs(workspace.Folder:GetChildren()) do
	task.spawn(function()
		repeat wait(1)
			if dropper.Parent == workspace.PlayerBuilt then
				print("yoyoy")
			repeat wait(1)
				local product = Instance.new("Part", workspace.DropperParts)
				product.Anchored = false
				product.CanCollide = false
				product.Size = Vector3.new(1,1,1)
			until dropper == nil
		else
			print("Test", dropper.Parent)
		end 
		until dropper.Parent == workspace.PlayerBuilt
	end)
end

There could be a few things wrong with your code:

  • The script you are showing is a server script and the script moving the droppers into the “PlayerBuilt” folder is a local script
  • You did not tag your objects correctly

There may be other things things that could be going wrong, but these are probably the most likely. Are you able to attach a picture of the collection service tag you created, and also explain the method you are using to move the dropper to the “PlayerBuilt” folder?