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

I need help to make a brick that regens after 5 secs

Asked by
Yeevivor4 155
10 years ago

I made a brick named "FF3" that contained the script to move Engine and Wing1. I want to make the "FF3" brick disappear for 5 seconds then come back, after being touched.

Engine = script.Parent.Parent.Engine
Wing1 = script.Parent.Parent.Wing1

function onTouched(hit)
     local human = hit.Parent:findFirstChild("Humanoid")
     if (human ~= nil) then
        for loop = 1, 100 do
    Engine.CFrame = Engine. CFrame *CFrame.new(0, 0, -.1) -- z makes it move forwad
     wait(1/25)
    Wing1.CFrame = Wing1.CFrame *CFrame.new(0, 0, .1)
    wait(1/25)

        end
    end
 end
    script.Parent.Touched:connect(onTouched)

~Thanks for reading and helping,

~Yeevivor4

2 answers

Log in to vote
1
Answered by
AxeOfMen 434 Moderation Voter
10 years ago
Engine = script.Parent.Parent.Engine
Wing1 = script.Parent.Parent.Wing1
BrickToHide = script.Parent

local function hideBrickFor5Seconds(brick)
    brick.Transparency = 1
    delay(5, function()
        brick.Transparency = 0
    end)
end

local activated = false --debounce to prevent activating repeatedly
function onTouched(hit)
    local human = hit.Parent:findFirstChild("Humanoid")
    if human and not activated then
        activated = true
        hideBrickFor5Seconds(BrickToHide) --If you want the block to be hidden BEFORE the engine and wings move, leave this here
        for loop = 1, 100 do
            Engine.CFrame = Engine. CFrame *CFrame.new(0, 0, -.1) -- z makes it move forwad
            wait(1/25)
            Wing1.CFrame = Wing1.CFrame *CFrame.new(0, 0, .1)
            wait(1/25)
        end
        --hideBrickFor5Seconds(BrickToHide) --If you want the block to be hidden AFTER the engine and wings move, uncomment this line
        activated = false
    end
end
script.Parent.Touched:connect(onTouched)
Ad
Log in to vote
0
Answered by 10 years ago

Simple,just put wait(5) x = Instance.new("Part",Workspace) --Always needs a parent x.Size=Vector3.new(100,100,100)-- For the size x.BrickColor=BrickColor.new'Bright red'--Color strings for the simplicity

Answer this question