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

How to unanchor a model from a script AFTER a specific time?

Asked by 6 years ago
Edited 6 years ago

Hi, i have been looking for hours how to do it but couldn't find anything. Does anyone know how to unanchor a model from a script AFTER a specific time? Lets say if map (Model) named (Map1) spawns in, then after 5 seconds the whole map will unanchor.

Map changing script

while true do
    game.Lighting.Map1:clone().Parent = game.Workspace
    wait(10) --Change this to the time between each map. Goes in seconds not minutes or hours. You can do min. or hrs. if u know how much seconds are on there.
    local msg = Instance.new("Message")
    msg.Parent = game.Workspace
    msg.Text = ("Loading next map")--Change this to the title of the map.
    wait(4)
    msg:remove()
    game.Workspace.Map1:remove()
    wait(2)

    game.Lighting.Map2:clone().Parent = game.Workspace
    wait(10)--Change this to the time between each map.
    msg.Parent = game.Workspace
    msg.Text = ("Loading next map")--Change this to the title of the map.
    wait(4)
    msg:remove()
    game.Workspace.Map2:remove()
    wait(2)

    game.Lighting.Map3:clone().Parent = game.Workspace
    wait(10)--Change this to the time between each map.
    msg.Parent = game.Workspace
    msg.Text = ("Loading next map")--Change this to the title of the map.
    wait(4)
    msg:remove()
    game.Workspace.Map3:remove()
    wait(2)

end 

2 answers

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago

You can use GetDescendants() instead of GetChildren(). The difference is that GetDescendants() gets ALL of the contents (including other models inside the model) while GetChildren() only gets the model's contents you assigned to (only gets children to one model).

wait(5)
local Descendants = MapModel:GetDescendants()

for i = 1, #Descendants do 
    local child = Descendants[i]
    if child:IsA("BasePart") then 
        child.Anchored = false 
    end
emd
0
Could you please show me how should i use it in my script i mentioned? MarkusMape 22 — 6y
0
Got it worked, thanks. But the problem continues. How do i make it that if it map gets unanchored then it wont start breaking/falling by itself. I want that only players and disasters can break map blocks. MarkusMape 22 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Well you could use a for loop (as far as i know)

Like this (assuming Map1 is already in workspace):

wait(5)
for i,v in pairs (workspace.Map1:GetChildren()) do
    if v:IsA("BasePart") then  -- to exclude decals and whatnot
    v.Anchored = false
    end
end
0
indent line 4 por favot awfulszn 394 — 6y
0
I sent you a Private message on roblox. MarkusMape 22 — 6y

Answer this question