I'm trying to make a button that makes a model anchored when clicked with a bool value called "DummyIsNPC"

Hey there, I’m trying to make a button that makes a model anchored when clicked with a bool value called “DummyIsNPC” in a folder called Container but it doesn’t work, can someone help?
Screenshot 2022-10-23 101703
script:

function clicked()
	game.Workspace.Container:FindFirstChild("CanCleanup")
	for i,v in pairs(workspace:GetChildren()) do
		if v.Name == "Container" then
			for s,q in pairs(v:GetChildren()) do
				q:FindFirstChild("CanCleanup")
				if q.CanCleanup.Value == true then
					q.Anchored = true
				end
			end
		end
	end
end

			
script.Parent.MouseButton1Click:connect(clicked)

Anchored isn’t a property models have, only the BasePart class (which includes parts, meshparts, etc.) has it. To anchor the model you will need to anchor the root part (for example, HumanoidRootPart)

1 Like