Script Either Isn't Cycling Through Body Parts or Isn't Anchoring

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    To fix my script.

  2. What is the issue? Include screenshots / videos if possible!
    It’s not anchoring.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

for _,v in pairs(target:GetChildren()) do
			if v:IsA("BasePart") then
				v.Anchored = true
			end
		end
		task.wait(5)
		for _,v in pairs(target:GetChildren()) do
			if v:IsA("BasePart") then
				v.Anchored = false
			end
		end
end

try using print(v.Name) inside the loop and check if everything prints…

1 Like

There seems to random end at the bottom of the script, that doesn’t belong, but I’ll just assume you only sent a snippet of your script and didn’t post your whole script. If that is the case, it’d be helpful to get more information.

To what I can see the script itself should work, as long as, the “Target” is a character model or a model/folder/etc, with BaseParts in it.

Here’s a tiny edited version of the script that may or may not wokr

for i,v in ipairs(target:GetChildren()) do
			if v:IsA("Part") then
print(v.Name)
				v.Anchored = true
			end
		end

		task.wait(5)

		for i,v in pairs(target:GetChildren()) do
			if v:IsA("Part") then
				v.Anchored = false
			end
		end

I found the solution, it wasn’t that part of the script, I realised I forgot to add the player parameter for the OnServerEvent, so It was anchoring myself.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.