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

How do i make the bodycolors turn back to normal after a second in this for loop?

script.Parent.Humanoid.HealthChanged:Connect(function(health)
	for i, v in pairs(script.Parent:GetChildren()) do
		if v:IsA("BasePart") then
			v.BrickColor = BrickColor.new("Really red")
		end
	end
end)

right after line 4, how would i make a wait and then add the colors back to normal? I have been wondering how to do it because i am making an adventure/RPG game.

Thanks.

2 answers

✓ Accepted answer

You can save the color inside a table then apply it later, similar to this:

local Colors = {}
local Brick = {}

script.Parent.Humanoid.HealthChanged:Connect(function(health)
    for i, v in pairs(script.Parent:GetChildren()) do
        if v:IsA("BasePart") then
            Colors[i] = v.BrickColor
            Brick[i] = v
            v.BrickColor = BrickColor.new("Really red")
        end
    end
    wait(1)
    for i=1,#Brick do
        Brick[i] = BrickColor.new(Colors[i])
    end
    Brick = {}
end)

5 comments

0

It says there is an error on line 13. I did the exact same you did on line 13, What do i need to do now?

0

oh I see, I'll fix it

0

ok I fixed it, try it now

0

I hope these dont annoy you but the is still an error, it is saying on line 14 that i cant use brickcolor.new() with color3s.

0

Its ok, it's why I'm here after all. Then try using Color3.new instead of the BrickColor.new.

Try This:

script.Parent.Humanoid.HealthChanged:Connect(function(health)
for i, v in pairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.BrickColor = BrickColor.new("Really red")
wait(1)
v.BrickColor = BrickColor.new("Medium stone grey") -- This Is Default
end
end
end)

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