Is it possible to select all parts in model and anchor it with only one script. For example, I have 500 part in model and I want all of them to anchor and then unchor it after 15 second, how can I do that?
If you want to click / press the models, this might help -
https://developer.roblox.com/en-us/api-reference/function/Selection/Get
A simple example of what you can do:
local model = workspace.Model
for i, v in pairs(model:GetDescendants()) do -- this get severy single thing inside the model, for every single thing inside that model do:
if v:IsA("Part") then -- check if the child is a part
v.Anchored = true -- v is the part
end
end
Find out more here:
https://education.roblox.com/en-us/resources/pairs-and-ipairs-intro
2 Likes
local Workspace = workspace
local Model = Workspace.Model --Reference to model.
for _, Descendant in ipairs(Model:GetDescendants()) do
if Descendant:IsA("BasePart") then
Descendant.Anchored = true
end
end
1 Like
with only one script,
I want all of them to anchor and then unchor it after 15 second
The op did clarify.
local Workspace = workspace
local Model = Workspace.Model --Reference to model.
local Descendants = Model:GetDescendants()
for _, Descendant in ipairs(Descendants) do
if Descendant:IsA("BasePart") then
Descendant.Anchored = true
end
end
task.wait(15)
for _, Descendant in ipairs(Descendants) do
if Descendant:IsA("BasePart") then
Descendant.Anchored = false
end
end
2 Likes