Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont my unanchor script work, it says that it is not a valid function?

local part = script.Parent.Parent
part.Anchored = false

5 comments

0

whats the directory?

0

It might be, because you're trying to unanchor an object which doesn't have a property called "Anchored", Remember, only Base Parts (Wedges, Bricks, MeshParts and so on) have a property called "Anchored". Make sure that the part you're trying to unanchor is actually a BasePart, and not a model or other object.

0

i dont know

0

As @MysteriousCeburek said, make sure it's a base part and not a model. If it's a model, lua will start looking for a part inside the model called "Anchored" and won't find one.

0

add only one parent

2 answers

What are you trying to Unanchor? A BasePart or a Model? It has to be a base part (wedge, part, cylinder, etc) to use the UnAnchor function. If it’s a model you would have to unanchor all of the parts in it. Like this:

local model = script.Parent
local Part1 = model.Part
local Part2 = model.Wedge
Part1.Anchored = false
Part2.Anchored = false

If you are trying to unanchor a model then just do a loop through it and find the baseparts.

local Model = script.Parent.Parent -- Assuming That is the model

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

Otherwise if script.Parent.Parent is not a model and not a basepart Anchored is not a property.

This discussion is preserved as it was. New answers, comments, and votes are closed.