Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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)

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

This discussion is preserved as it was. New answers, comments, and votes are closed.