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

Color3 Values not setting correctly?

Script is supposed to turn the model into red for 0.2 seconds then return back to it's original colour, but the model just turns black. Any ideas why?

for i, v in pairs(Object:GetChildren()) do -- looping through the object.
	if v:IsA("Part") and v.Name ~= "PrimaryPart" then
		local ColourTag = Instance.new("Color3Value")
		ColourTag.Parent = v
		ColourTag.Name = "ColourTag"
		ColourTag.Value = v.Color
		v.Color = Color3.fromRGB(255, 0, 0) -- make it red.
	end
end
wait(0.2)
for i, v in pairs(Object:GetChildren()) do -- looping through the object.
	if v:IsA("Part") and v.Name ~= "PrimaryPart" then
		v.Color = Color3.new(v:FindFirstChild("ColourTag").Value) -- make it the original colour.
	end
end

1 answer

✓ Accepted answer

Although Color3 could be used, it's best to use BrickColor.

local Object = workspace.obj --Wherever the object model is.
for i, v in pairs(Object:GetChildren()) do -- looping through the object.
    if v:IsA("Part") and v.Name ~= "PrimaryPart" then 
		local color = Instance.new("BrickColorValue") --New BrickColor Value
		color.Parent = Object
		color.Value = v.BrickColor
		v.BrickColor = BrickColor.new(255,0,0) --Red
		wait(0.2) --You can just add a wait here
		v.BrickColor = color.Value --Change back to original
    end
end

Please accept my answer if this helped! Thanks!

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