#im trying to make it unanchor all the parts inside of the model but its not working

1 messages · Page 1 of 1 (latest)

flat warren
#

local player = game.Players.LocalPlayer
local click = game.Workspace.Map.LockedDoors.Lock.Locked:WaitForChild("Cube").ClickDetector

local function unanchorAllChildren()
    local lockModel = workspace.Map.LockedDoors:FindFirstChild("Lock")
    if lockModel then
        local modelsToCheck = {"Locked", "Chain"}
        for _, modelName in ipairs(modelsToCheck) do
            local model = lockModel:FindFirstChild(modelName)
            if model then
                for _, child in model:GetDescendants() do
                    if child:IsA("MeshPart") then
                        child.Anchored = false
                    end
                end
            else
                warn(modelName .. " model not found in Lock")
            end
        end
    else
        warn("Lock model not found in LockedDoors")
    end
end

if click then
    click.MouseClick:Connect(function()
        local key = player.Backpack:FindFirstChild("Key100M")
        if key then 
            unanchorAllChildren()
        end    
    end)    
end
lyric hatch
#

model:GetDescendants() should be model:GetChildren() I think that should resolve your issue

flat warren
lyric hatch
#

are you trying to unanchor the character model or a door?

flat warren
#

im trying to unanchor the lock and the chain so it falls down

lyric hatch
#

is the entire model not unanchoring or only parts

flat warren
#

nothing is unanchoring

#

want me to give you a screen recording?

lyric hatch
#

sure

#

is there an error message?

flat warren
#

idk how to get it so its in discord

flat warren
lyric hatch
#

can I see the hierarchy for the model

flat warren
#

is this was you were looking for?

lyric hatch
#

yeah

#
 if lockModel then
        local locked = Lock:FindFirstChild("Locked"):GetChildren -- Gets children of locked model
        local chain = Lock:FindFirstChild("Chain"):GetChildren -- Gets children of chain model
        locked.Anchored = false -- Unanchores
        chain.Anchored = false -- Unahchores
else
        warn(modelName .. " model not found in Lock")
end
#

this should work but there might be something that doesn't..

#

lmk : )

#

@flat warren

flat warren
#

okay lemme test this out man tysm

lyric hatch
#

don't thank me yet, gotta see if it works

flat warren
#

theres errors

lyric hatch
#

hover over, what does it say

#

oh wait, sorry! replace "Lock" with lockModel

flat warren
lyric hatch
#

does that resolve? or still there

flat warren
#

cant you not use : after ()?

lyric hatch
#

lemme test this

flat warren
#

would this be better ?

#

nope it would mb

lyric hatch
#

um, ok :GetChildren should have () after mb

#

but um, I'm trying a simpler version and it's not unanchoring so we've come full circle Dx

flat warren
#

lol thanks for trying

#

wait is the problem that i have it in startgui?

lyric hatch
#

nah this aint done till I get this 🙏

#

no that shouldnt be an issue

#

the issue is it can't locate the "anchored" from the list of parts but it should be able to cuz there's no error

flat warren
#

ik i was trying to figure out this problem for days

raven wagon
lyric hatch
#

shut your squiggle diggle I got it

#
local mainModel = workspace.MainModel
if mainModel then
    local mainModelChildren = mainModel:FindFirstChild("Model"):GetChildren()
    print(mainModelChildren)
    for i, ChildrenCount in ipairs(mainModelChildren) do
        ChildrenCount.Anchored = false -- finds the anchored property in the tabled parts and sets it to false
    end
end
#

you'll have to rename stuff to make it work for your script @flat warren but this does work

raven wagon
lyric hatch
#

the code is for a door that shouldn't be accessed by everyone if they don't have the key. It's purely cosmetic when it unanchors

daring riverBOT
#

studio** You are now Level 4! **studio

raven wagon
#

and by weird, i mean weird like this. this is just a truss i unanchored on the client and pushed it over, but its anchored on the server.

lyric hatch
#

looks fine to me

#

I think he wants the door to unanchor and fall through the floor so this wouldn't be an issue either way

flat warren
#

yea it didnt work

full carbon
lyric hatch
flat warren
#

unanchor all the parts inside of a model

lyric hatch
#

cuz local doesn't seem to work

#

but a normal script does

flat warren
#

i dont want it to be a server script because i want it to be only seen by the person that unlocks it

full carbon
#

this is the most simplest script to unanchor every parts on a model

lyric hatch
#

noo! you stole my work!

#

and made it bettter! how could you

raven wagon
#

it captures parts, unions, and meshparts on its own

full carbon
lyric hatch
#

@raven wagon how long have you been coding on studio

full carbon
#

people said basepart was just a mesh part itself

#

so

#

🤷‍♂️

lyric hatch
#

mb I did not mean to ping the other guy

raven wagon
#

ye i not the only one with this name

#

surprisingly

full carbon
#

pyro fyre

#

🔥

raven wagon
#

many more years on other projects

lyric hatch
raven wagon
#

coz roblox doesn't have one that can do prediction properly

lyric hatch
#

wym replication system

raven wagon
#

the thing that keeps server and clients all in sync and seeing the same world at the same time

lyric hatch
#

ooh yeah that is so ass

#

is it a ping problem? ik other games generally peak at 25-30 ping while roblox averages 60-150

lyric hatch
#

yeah I can see why you'd want to script your own Dx

flat warren
#

My internet is literally so shit it makes me wanna kill myself

lyric hatch
#

r e a l

#

but only on pvp games

flat warren
#

I can’t load Roblox studio I gotta type on discord on my phone

lyric hatch
#

oh it's so over for you 💀

raven wagon
# lyric hatch but only on pvp games

nah it applies to pve too, see studio has 0 ping. the latency you're seeing is actually physics replication, which is intentionally delayed by about 50ms, have to account for that too

raven wagon
#

yes

lyric hatch
#

I think studio has ping

raven wagon
#

if you do player:getnetworkping() in studio it returns 0

#

coz there is no ping

lyric hatch
#

that makes sense then

raven wagon
#

anyway this thread is about your anchoring thing, not this

#

peace salute

lyric hatch
#

this isn't even my thread 😭

flat warren
#

do yall know how to fix this 23:22:24.024 Cube is not a valid member of Model "Workspace.Map.LockedDoors.Lock.Locked" - Client - LocalScript:2

#

my cube is part of thelocked model

flat warren
#

@full carbon this didnt work idk whats going on ```
local click = game.Workspace.Map.LockedDoors.Lock.Locked:WaitForChild("Cube").ClickDetector

click.MouseClick:Connect(function()
local lockmodel = game.Workspace.Map.LockedDoors.Lock.Chain

for _, d in pairs(lockmodel:GetDescendants()) do
    if d:IsA("Part") or d:IsA("MeshPart") then
        d.Anchored = false
    end
end

end)```

flat warren
flat warren
#

there is no error

#

It’s studio just bugging?

#

Is*

mighty ermine
flat warren
#

Lurking 🥀

flat warren
#

should i use a remote event to do the unanchoring @everyone

full carbon
flat warren
#

Yea

flint sundial