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

How would I regen this model in the same position after making it fall and dissapear?

Asked by
c_ld 2
6 years ago
Edited 6 years ago

So I have been learning scripting for a few days now, and I made this script that makes the stairs turn black, go through the ground, and unanchor. But I can't figure out how to regen this model. I tried cloning it several ways but that didn't work. (Maybe I am doing it wrong) Please help guys!

local Model = game.Workspace.Stairs

for _,v in pairs(Model:GetChildren()) do
    if v:IsA("BasePart") then
        v.Touched:connect(function(Hit)
            if Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then
                v.Color = Color3.new(0,0,0) --Color turns black
                wait(0.3)
                v.CanCollide = false
                v.Anchored = false
            end
        end)
    end
end
0
You could turn them back anchored and collidable after a certain time before they fall to the void...you could make clones by doing local x = v:Clone() v.Anchored = false wait(sometime) x.Parent = V'sParent...you could reanchor them when they hit a certain height Vulkarin 581 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Well, once they fall into the void, they're gone.

Your script is a solid base, though.

local Model = game.Workspace.Stairs

for _,v in pairs(Model:GetChildren()) do
    local debounce = false
    if v:IsA("BasePart") then
        v.Touched:connect(function(Hit)
            if Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") and debounce == false then
                local stairclone = v:Clone()
                stairclone.Parent = Model
                v.CanCollide = false
                v.Transparency = 1
                debounce = true
               stairclone.Color = Color3.new(0,0,0) --Color turns black
               wait(0.3)
               stairclone.CanCollide = false
               stairclone.Anchored = false
                wait(5)
                v.CanCollide = true
                v.Transparency = 0
                debounce = false
            end
        end)
    end
end

It clones the stair prior to it falling and regens 5 seconds after falling. There is also a 'debounce' put in, for each part. If you have stood on the part. It will activate the debounce so it won't keep creating clones. As the for loop will not update to see a clone, the clone is merely the falling stair, whilst the actual stair is turned transparent and non-collidable.

I hope this helped.

Thanks,

Explosion

0
I will check it out tomorrow, thank you so much. c_ld 2 — 6y
0
Update: it worked, thank you so much! c_ld 2 — 6y
Ad

Answer this question