In the script doesn't unanchored item

I ran into a problem, I disable Anchored in the script, but it either doesn’t work or I don’t know what. Below I attach a script (server) and a video for it.

System.MakeCharacter.OnServerEvent:Connect(function(player, modelname, currentdivison, loc)
	local Character = player.Character
	if Character:FindFirstChild(modelname) then
		Character[modelname]:Destroy()
	else
		local HeadDressMake = System.Fractions[player.Team.Name][currentdivison][loc][modelname]:Clone()
		if HeadDressMake.Name == "Gloves" then
		local GloveL = System.Fractions[player.Team.Name]["Nitrile GlovesL"]:Clone()
		local GloveR = System.Fractions[player.Team.Name]["Nitrile Gloves"]:Clone()
		GloveR.Parent = Character
		GloveL.Parent = Character
		local CustomWeld1 = Instance.new("Weld")
		CustomWeld1.Parent = GloveL.Middle
		CustomWeld1.Part0 = Character[GloveL.WeldTo.Value]
		CustomWeld1.Part1 = GloveL.Middle
		GloveL.Middle.Anchored = false
		local CustomWeld2 = Instance.new("Weld")
		CustomWeld2.Parent = GloveR.Middle
		CustomWeld2.Part0 = Character[GloveR.WeldTo.Value]
		CustomWeld2.Part1 = GloveR.Middle
		GloveR.Middle.Anchored = false
	else
		HeadDressMake.Parent = Character
		local Weld = Instance.new("Weld")
		Weld.Parent = HeadDressMake.Middle
		Weld.Part0 = Character[HeadDressMake.WeldTo.Value]
		Weld.Part1 = HeadDressMake.Middle
			print("anchor false")
			HeadDressMake.Middle.Anchored = false
			if HeadDressMake:FindFirstChild("UI") then
				local GUI = System.UIs[HeadDressMake.UI.Value]:Clone()
				GUI.Parent = player.PlayerGui
				if player.PlayerGui:FindFirstChild(HeadDressMake.UI.Value) then
					player.PlayerGui[HeadDressMake.UI.Value].KitName.Value = HeadDressMake.Name
				end
			end
		end
	end
end)

robloxapp-20240603-1252528.wmv (973,8 КБ)

I also want to add that this doesn’t happen in another place, but here it is exactly like that

Are there any other scripts that interfere with glover.middle? Have you checked error logs? Did you also try a debug script so that it prints if its anchored or not?

not glover.middle, but headDressMake. Nothing prevents it from working, no scripts, it only has a weld script, which is needed for an item to be attached to a certain part of the character. Below I attach a weld script (server) in the model .

local WeldTo = script.Parent.Middle

function Weld(Model)
    for i,v in pairs(Model:GetChildren()) do
        if v:IsA("BasePart") and v.Name ~= "Middle" then
            
            local Weld = Instance.new("Weld",WeldTo)
            Weld.Part0 = WeldTo
            Weld.Part1 = v
            Weld.C0 = WeldTo.CFrame:ToObjectSpace(v.CFrame)
            v.Anchored = false
        end
        Weld(v)
    end
    WeldTo.Anchored = true
end

Weld(script.Parent)
script:Destroy()

WeldTo.Anchored = true? are u sure

In order for it to be attached to the character, but then in the first script anchored = false

let me try to write a debug script real quick

Sorry, if this is taking too long, I’m helping my parents.

Not so good at script design but this is the best I can do: [Edited: I would recommend putting it at the end of the script, so nothing goes wrong.

if objectdirectoryhere.Anchored == true then
	print("anchored: true")
 else
	print("anchored:false")
	end

in output anchor = false but when I click continue (in my locker) then anchor = true

Review the locker script, it probably interferes with it.

everything is fine with it, because in my other places everything works fine

Does it fire a remoteevent? just wondering

Does the item have multiple parts? Try using a for loop to unanchor every part if so

it consists of several parts, but only one part “Middle” is attached

1 Like

It could still be the issue though. Try using a for loop to unanchor every part

I made it:

for i,v in pairs(HeadDressMake:GetChildren()) do
			print(v.Name)
			if v:WaitForChild("Middle") then
				v.Middle.Anchored = false
			end
		end

But still the model is anchored = true
Infinite yield possible on :WaitForChild(“Middle”)’ - Studio

Maybe try

for i,v in pairs(HeadDressMake:GetChildren()) do
			print(v.Name)
		        if v:IsA("BasePart") then
                v.Anchored = false
           end
		end

the same thing happens with your script

What name is it supposed to search for?