[EDIT] I AM NOT USING 2 SCRIPTS. THESE ARE THE SAME SCRIPT JUST DIFFERENT SECTIONS
So i have a path (10 blocks wide). I have 1 block changed colour at a time and making it's way to other side, and it cycles through forever. Changing the colour works fine.
My problem is that I only want the block that has changed colours to be a KillBrick; however, the blocks never reset back to a normal one.
Here's my killbrick part of the code
local function kill(hit)
local t = currentBrick.BrickColor == BrickColor.new("Really red")
if killOn and t then
hit.Parent.Humanoid.Health = 0
end
print("hit", killOn, t, currentBrick.BrickColor)
end
Print statement is for testing purposes.
Here is how i'm alternating blocks
while true do
for index, brick in pairs(objects) do
--THIS SHOULD MAKE THE KILL BRICK
killOn = true
brick.BrickColor = BrickColor.new("Really red")
currentBrick = brick
brick.Touched:Connect(kill)
wait(2)
--THIS SHOULD RETURN THE BRICK BACK TOA NORMAL ONE
killOn = false
brick.BrickColor = BrickColor.new("White")
currentBrick = brick
brick.Touched:Connect(kill)
end
end
What exactly am i doing wrong here?

2 comments
I am not using 2 scripts. I was merely showing to parts of the same script instead of posting the entire thing.
Sorry about that; edited/updated answer