Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
local part = script.Parent.Parent
part.Anchored = false
0
whats the directory? rookiecookie153 53 — 4y
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. MysteriousCeburek 27 — 4y
0
i dont know ShinyPhenomenal -3 — 4y
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. Recrucity 13 — 4y
0
add only one parent Djquee03 0 — 4y

2 answers

Log in to vote
0
Answered by
Nozazxe 107
4 years ago

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
Ad
Log in to vote
0
Answered by
LuaDLL 253 Moderation Voter
4 years ago

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.

Answer this question