Changing bool value in a for loop

You can write your topic however you want, but you need to answer these questions:

  1. **What do you want to achieve?A floor is lava game. The floor should do damage after a certain time and return to normal. Everything in a loop

  2. What is the issue? The problem is that the floor stays red for the rest of the time and does not go to normal again

  3. What solutions have you tried so far? I did look the problem up in the dev hub but couldn’ t really find anything or it was too hard to understand

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

print("The floor is lava in...")

for countdown = 1, 20 do --basically kills you after counting to 12, but stays a killerfloor and that' s just bad, so gotta work on this in the future!--
	local afterdead = true
	wait(1)
	print(countdown)
	if afterdead == true then
		do
			if countdown == 12 and afterdead == true then
				script.Parent.BrickColor = BrickColor.new("Really red")
				script.Parent.Material = Enum.Material.Cobblestone
				wait()
				script.Parent.Touched:Connect(function(hit)
					if hit and hit.Parent:FindFirstChild("Humanoid") then
						hit.Parent.Humanoid.Health = 0	
						if countdown==0 then
							wait(10)
							print(countdown)
							if afterdead == true and countdown == 20 then -- if 20, then no damage 
								afterdead = false
								wait(10)
								script.Parent.BrickColor= BrickColor.new("Really black")
								script.Parent.Material = Enum.Material.Ice


							end

						end


					end
				end)

			end
		end


		end
	end
	

Sorry if I made some mistakes, it’ s my first post here. So tell me if I did something wrong. Thanks!

1 Like

Hi. You can format the code in your post with the “Preformatted Text” button (looks like this: </>).

Oh, thank you so much. It’ s way easier to read now.

1 Like