Can't unchor Instance

Even tho I write for the part to get unchored, it does not work. I already checked and searched, but I haven’t find the problem yet.

Full Script
local Tool = script.Parent

local AXE_POWER = 22

local TotalCountdown = 2
local Countdown = 0

Tool.Activated:Connect(function()

	--Countdown
	if Countdown ~= 0 then
		return
	end

	print("Axe hit: " .. AXE_POWER)
	Countdown = TotalCountdown

	task.spawn(function()
		while Countdown > 0 do
			wait(1)
			Countdown -= 1
		end
	end)

	local HumanoidRootPart = Tool.Parent:FindFirstChild("HumanoidRootPart")

	--Hitbox Spawn
	local hitbox = Instance.new("Part")
	hitbox.Size = Vector3.new(5, 5, 5)
	hitbox.Transparency = .5
	hitbox.BrickColor = BrickColor.Red()

	local hitboxClone = hitbox:Clone()
	hitboxClone.Parent = workspace
	hitboxClone.CanCollide = false
	hitboxClone.CFrame = HumanoidRootPart.CFrame * CFrame.new(0, 0, -4)

	task.spawn(function()
		task.wait(1)
		if hitboxClone then
			hitboxClone:Destroy()
		end
	end)

	--Hitting Tree
	local hit = workspace:GetPartBoundsInBox(HumanoidRootPart.CFrame * CFrame.new(0, 0, -4), Vector3.new(5, 5, 5))
	
	local Tree
	local Wood

	local TreeHealth

	for _, part in ipairs(hit) do
		if part.Name == "Wood" then
			
			Tree = part.Parent
			Wood = Tree:FindFirstChild("Wood")
			TreeHealth = Tree:FindFirstChild("HealthValue")

			if Wood and TreeHealth then
				--Sound
				task.spawn(function()
					local Sound = Instance.new("Sound")
					Sound.SoundId = "rbxassetid://8394333801"

					local PitchEffect = Instance.new("PitchShiftSoundEffect")
					local PitchEffectClone = PitchEffect:Clone()

					local SoundClone = Sound:Clone()

					PitchEffectClone.Parent = SoundClone
					PitchEffectClone.Octave = math.random(99, 111) / 100

					SoundClone.Parent = part
					SoundClone:Play()

					SoundClone.Ended:Connect(function()
						SoundClone:Destroy()
					end)
				end)

				break
			end
		end
	end

	--Check Tree Health
	if TreeHealth == nil then return end

	TreeHealth.Value -= AXE_POWER


	if TreeHealth.Value <= 0 then
		for _, part in Tree:GetChildren() do
			if part:IsA("Part") then
				part.Anchored = false
				Wood.CanCollide = false
			end
		end

		local wood = Instance.new("Part")
		wood.Color = Wood.Color
		wood.Size = Vector3.new(1, 1, 3)
		wood.Material = Enum.Material.Wood
		wood.Position = Wood.Position
		wood.Anchored = false
		wood.Parent = workspace

	end
end)

Line that might be the problem:

for _, part in Tree:GetChildren() do
			if part:IsA("Part") then
				part.Anchored = false
				Wood.CanCollide = false
			end
		end

		local wood = Instance.new("Part")
		wood.Color = Wood.Color
		wood.Size = Vector3.new(1, 1, 3)
		wood.Material = Enum.Material.Wood
		wood.Position = Wood.Position
		wood.Anchored = false
		wood.Parent = workspace

So, is the problem the anchor isn’t working or the unanchor isn’t working? Which one is it?

could you please put in a screen shot of the error because it will tell us won’t line is the problem.

The part is getting anchored even tho I want it unchored

Are your codes running on the server?

Yeah, they are a normal script inside the Tool.

Try inserting the codes below and check it points that part if you click Part’s name and check wood.Anchored again in the Output.

print(wood, wood.Anchored)

imagem_2025-07-27_021257936
its getting the part correctly, but even tho it’s saying that it’s unchored, it is actually anchored

New parts by default aren’t anchored, this might be a shot in the dark but just try removing that line and running the code and see if it works.

13 Likes

If you check the anchor of the part on the server instead of the client, is there any difference? If the anchor is the same, try to find codes in other scripts that might interfere with it.

nop, It is still getting anchored. I even tried to try to set the NetworkOwner to the player to see if that was the problem. It wasn’t

Try changing the woods position?

13 Likes

Aren’t position and anchor unrelated?

tried and they are unrelated actually unrelated

Have you tried giving your new block an assigned name instead of just “Part”?

13 Likes

If possible, could you please attach a copy of the game file? It is difficult to find the cause as of now.

I fixed it. I just needed to set a wait() for it to work

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