How to make a disappearing brick handler

Is it really worth having a while loop here? It just seems like something that would create unnessecary lag since you are constantly iterating through the folder and connecting a new event each time.

Something like this might work better:

local folder = game:GetService("Workspace"):WaitForChild("Folder")

local function Setup(part)
	local debounce = false
	part.Touched:Connect(function(hit)
		local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		if (plr and not debounce) then
			debounce = true
			part.Transparency = 1
			part.CanCollide = false
			wait(2)
			part.Transparency = 0
			part.CanCollide = true
			wait(2)
			debounce = false
		end
	end)
end

for i,v in pairs(folder:GetChildren()) do
	Setup(v)
end
1 Like

Looks fine, tell me if it works.

https://www.youtube.com/AlvinBlox is a good channel for scripting

1 Like

yea it worked__________________________

i know but sometimes i dont understand

nice, and you should definetly watch alvinblox

now i got another problem with flashing brick handle idk why its flash one by one not all of them flash at the same time
here is the script:
local folder = workspace:FindFirstChild(ā€œFolderā€)

while true do
wait()
for i,v in pairs(folder:GetChildren()) do
local brick = v
brick.Transparency = 0.1
wait()
brick.Transparency = 0.2
wait()
brick.Transparency = 0.3
wait()
brick.Transparency = 0.4
wait()
brick.Transparency = 0.5
wait()
brick.Transparency = 0.6
wait()
brick.Transparency = 0.7
wait()
brick.Transparency = 0.8
wait()
brick.Transparency = 0.9
wait()
brick.Transparency = 1
brick.CanCollide = false
wait(1)
brick.Transparency = 0.9
wait()
brick.Transparency = 0.8
wait()
brick.Transparency = 0.7
wait()
brick.Transparency = 0.6
wait()
brick.Transparency = 0.5
wait()
brick.Transparency = 0.4
wait()
brick.Transparency = 0.3
wait()
brick.Transparency = 0.2
wait()
brick.Transparency = 0.1
wait()
brick.Transparency = 0
brick.CanCollide = true
end
end

well, here’s a updated script

while true do
wait()
for i,v in pairs(folder:GetChildren()) do
local brick = v
local tweenservice = game:GetService("TweenService")
 local tween = tweenservice:Create(brick,TweenInfo.new(0.3,Enum.EasingStyle.Quad,En um.EasingDirection.InOut),{Transparency = 1;})
tween.Completed:Connect(function()
brick.CanCollide = false
wait(1.3)
local tween1 = tweenservice:Create(brick,TweenInfo.new(0.3),{Transparency = 0;)}
tween1.Completed:Connect(function()
brick.CanCollide = true
end)
tween1:Play()
end)
tween:Play()
end
end

did you type something wrong?


err:
[- ServerScriptService.Script:10: Expected identifier when parsing expression, got ā€˜)’]

updated:

while true do
wait()
for i,v in pairs(folder:GetChildren()) do
local brick = v
local tweenservice = game:GetService(ā€œTweenServiceā€)
local tween = tweenservice:Create(brick,TweenInfo.new(0.3,Enum.EasingStyle.Quad,En um.EasingDirection.InOut),{Transparency = 1;})
tween.Completed:Connect(function()
brick.CanCollide = false
wait(1.3)
local tween1 = tweenservice:Create(brick,TweenInfo.new(0.3),{Transparency = 0;})
tween1.Completed:Connect(function()
brick.CanCollide = true
end)
tween1:Play()
end)
tween:Play()
end
end

its just turn to little transparent

what do you mean? can you send a picture

heres it updated i guess

while true do
wait()
for i,v in pairs(folder:GetChildren()) do
local brick = v
local tweenservice = game:GetService(ā€œTweenServiceā€)
local tween = tweenservice:Create(brick,TweenInfo.new(0.3),{Transparency = 1;})
tween.Completed:Connect(function()
brick.CanCollide = false
wait(1.3)
local tween1 = tweenservice:Create(brick,TweenInfo.new(0.3),{Transparency = 0;})
tween1.Completed:Connect(function()
brick.CanCollide = true
end)
tween1:Play()
end)
tween:Play()
end
end

1 Like

its flash rlly fast . you can go try it

idk how to record it to you ____________________________________

nvm i dont use that brick thx ---------------------------------

This wouldn’t work as errors can be ascociated with it aswell, it would be better to add a playerdb so for example if a player has touched it then the debounce is in effect for that specific player,

Adding a debounce for each brick is wrong because:

  • Assuming a player touches it and dies db is in effect and then in the time that db is set to false, a player can cross over it with 0 deaths